Merge branch '61-login-communication' into 'master'
Resolve "Login Communication" Closes #61 See merge request marcel.schwarz/2020ss-qbc-geofence-timetracking!50
This commit is contained in:
commit
fc813f14db
@ -53,6 +53,7 @@ public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilte
|
||||
HttpServletResponse res,
|
||||
FilterChain chain,
|
||||
Authentication auth) {
|
||||
res.setHeader("Access-Control-Expose-Headers", "Authorization");
|
||||
String token = JWT.create()
|
||||
.withSubject(((User) auth.getPrincipal()).getUsername())
|
||||
.withExpiresAt(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
|
||||
|
@ -56,7 +56,8 @@
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn icon @click="dialog = false"><v-icon>mdi-window-close</v-icon></v-btn>
|
||||
</v-card-actions>
|
||||
<SignIn />
|
||||
<SignIn v-on:signIn="signIn"/>
|
||||
<p id="loginError" ></p>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-row>
|
||||
@ -126,7 +127,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import SignIn from "./views/SignIn.vue";
|
||||
var baseUri = "http://backend:5000";
|
||||
export default {
|
||||
components: {
|
||||
SignIn
|
||||
@ -139,7 +142,31 @@ export default {
|
||||
login: true,
|
||||
dialog: false,
|
||||
menu: false
|
||||
|
||||
}),
|
||||
methods: {
|
||||
signIn (loginData) {
|
||||
|
||||
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (this.status == 200 & this.readyState ==4) {
|
||||
sessionStorage.setItem("jwt", this.getResponseHeader("Authorization"));
|
||||
location.reload();
|
||||
|
||||
|
||||
}else if(this.status != 200 && this.status !=0) {
|
||||
|
||||
document.getElementById("loginError").innerHTML="Login not successfull";
|
||||
}
|
||||
};
|
||||
xhttp.open("POST", baseUri + "/login", true);
|
||||
xhttp.send('{"username": "' + loginData.username +'", "password": "'+ loginData.password +'"}');
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
created() {
|
||||
this.$vuetify.theme.dark = true;
|
||||
}
|
||||
|
@ -22,12 +22,14 @@
|
||||
<v-text-field
|
||||
id="password"
|
||||
label="Password"
|
||||
v-model="password"
|
||||
name="Password"
|
||||
prepend-icon="mdi-key"
|
||||
type="password"
|
||||
color="primary"
|
||||
/>
|
||||
</v-form>
|
||||
<p id="missing"></p>
|
||||
</v-card-text>
|
||||
<div class="text-center mt-3">
|
||||
<v-btn rounded color="logowhite" outlined dark v-on:click="signin()">Sign In</v-btn>
|
||||
@ -121,14 +123,27 @@
|
||||
export default {
|
||||
data: () => ({
|
||||
step: 1,
|
||||
username: ""
|
||||
username: "",
|
||||
password: "",
|
||||
|
||||
}),
|
||||
props: {
|
||||
source: String
|
||||
},
|
||||
methods: {
|
||||
signin() {
|
||||
console.log(this.username);
|
||||
if (this.username != "" && this.password != "") {
|
||||
document.getElementById("missing").innerHTML= "";
|
||||
const loginData = {
|
||||
username: this.username,
|
||||
password: this. password
|
||||
}
|
||||
this.$emit('signIn', loginData);
|
||||
}else {
|
||||
document.getElementById("missing").innerHTML= "Please fill out all fields";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user