login communication
This commit is contained in:
parent
8b2e26042c
commit
efa7587702
@ -53,6 +53,7 @@ public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilte
|
|||||||
HttpServletResponse res,
|
HttpServletResponse res,
|
||||||
FilterChain chain,
|
FilterChain chain,
|
||||||
Authentication auth) {
|
Authentication auth) {
|
||||||
|
res.setHeader("Access-Control-Expose-Headers", "Authorization");
|
||||||
String token = JWT.create()
|
String token = JWT.create()
|
||||||
.withSubject(((User) auth.getPrincipal()).getUsername())
|
.withSubject(((User) auth.getPrincipal()).getUsername())
|
||||||
.withExpiresAt(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
|
.withExpiresAt(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
|
||||||
|
@ -56,7 +56,8 @@
|
|||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-btn icon @click="dialog = false"><v-icon>mdi-window-close</v-icon></v-btn>
|
<v-btn icon @click="dialog = false"><v-icon>mdi-window-close</v-icon></v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
<SignIn />
|
<SignIn v-on:signIn="signIn"/>
|
||||||
|
<p id="loginError" ></p>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
</v-row>
|
</v-row>
|
||||||
@ -126,7 +127,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import SignIn from "./views/SignIn.vue";
|
import SignIn from "./views/SignIn.vue";
|
||||||
|
var baseUri = "http://backend:5000";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
SignIn
|
SignIn
|
||||||
@ -139,7 +142,31 @@ export default {
|
|||||||
login: true,
|
login: true,
|
||||||
dialog: false,
|
dialog: false,
|
||||||
menu: 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() {
|
created() {
|
||||||
this.$vuetify.theme.dark = true;
|
this.$vuetify.theme.dark = true;
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,14 @@
|
|||||||
<v-text-field
|
<v-text-field
|
||||||
id="password"
|
id="password"
|
||||||
label="Password"
|
label="Password"
|
||||||
|
v-model="password"
|
||||||
name="Password"
|
name="Password"
|
||||||
prepend-icon="mdi-key"
|
prepend-icon="mdi-key"
|
||||||
type="password"
|
type="password"
|
||||||
color="primary"
|
color="primary"
|
||||||
/>
|
/>
|
||||||
</v-form>
|
</v-form>
|
||||||
|
<p id="missing"></p>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<div class="text-center mt-3">
|
<div class="text-center mt-3">
|
||||||
<v-btn rounded color="logowhite" outlined dark v-on:click="signin()">Sign In</v-btn>
|
<v-btn rounded color="logowhite" outlined dark v-on:click="signin()">Sign In</v-btn>
|
||||||
@ -121,14 +123,27 @@
|
|||||||
export default {
|
export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
step: 1,
|
step: 1,
|
||||||
username: ""
|
username: "",
|
||||||
|
password: "",
|
||||||
|
|
||||||
}),
|
}),
|
||||||
props: {
|
props: {
|
||||||
source: String
|
source: String
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
signin() {
|
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