-
Notifications
You must be signed in to change notification settings - Fork 20
/
login.vue
72 lines (66 loc) · 1.65 KB
/
login.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<template>
<section class="container">
<div>
<form>
<div>
<label for="username">Username</label>
<input name="username" v-model="user.username" />
</div>
<div>
<label for="password">Password</label>
<input type="password" name="password" v-model="user.password" />
</div>
<div>
<button type="submit" @click.prevent="passwordGrantLogin">Login with Password Grant</button>
</div>
<div>
<button type="submit" @click.prevent="customPasswordGrantLogin">Login with Custom Passport Password Scheme</button>
</div>
</form>
</div>
<hr />
<div><button @click="oauthLogin">Login with OAuth</button></div>
</section>
</template>
<script>
export default {
auth: false,
data() {
return {
user: {
username: "",
password: ""
}
};
},
methods: {
async passwordGrantLogin() {
await this.$auth.loginWith("password_grant", {
data: {
grant_type: "password",
client_id: process.env.PASSPORT_PASSWORD_GRANT_ID,
client_secret: process.env.PASSPORT_PASSWORD_GRANT_SECRET,
scope: "*",
username: this.user.username,
password: this.user.password
}
});
this.$router.replace("/");
},
async customPasswordGrantLogin() {
await this.$auth.loginWith("password_grant_custom", {
data: this.user
});
this.$router.replace("/");
},
oauthLogin() {
this.$auth.loginWith("laravel.passport");
}
}
};
</script>
<style scoped>
div {
margin: 10px 0;
}
</style>