Blame view
src/pages/Authentication/Login.vue
6.93 KB
93a68cfa1
|
1 |
<template> |
03dcbf0c1
|
2 |
<v-app id="login"> |
93a68cfa1
|
3 4 |
<v-content> <v-container fluid fill-height> |
03dcbf0c1
|
5 6 7 8 9 10 11 12 |
<v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" :color="color" >{{ text }}</v-snackbar> |
93a68cfa1
|
13 |
<v-layout align-center justify-center> |
9b444e5c3
|
14 |
<v-flex xs12 sm10 md5 lg4> |
229463bd5
|
15 16 17 18 19 20 21 |
<img src="/static/icon.png" height="40" width="140" alt="logo" class="logo mx-auto mb-2" /> |
9b444e5c3
|
22 |
<v-card class="elevation-1 px-2 py-3 card" style="background-color: #7852cc" dark> |
7d0816758
|
23 24 25 26 |
<img src="/static/intrackIllustration.png" class="mx-auto logoSchool" style="display:block" |
9b444e5c3
|
27 |
width="280" |
7d0816758
|
28 29 |
/> <v-card-text align-center justify-center> |
e8965626f
|
30 |
<v-toolbar-title class="text-xs-center subheadline">SCHOOL LOGIN</v-toolbar-title> |
03dcbf0c1
|
31 32 |
<v-flex xs12 sm12 md12 lg12> <v-form ref="form" v-model="valid" lazy-validation> |
7d0816758
|
33 |
<label class="title">Email</label> |
03dcbf0c1
|
34 |
<v-text-field |
af414ec9c
|
35 |
style="padding: 0px; margin: 0px;" |
96f88269a
|
36 |
v-model.trim="userLogincredentials.email" |
03dcbf0c1
|
37 |
:rules="nameRules" |
7d0816758
|
38 |
placeholder="Enter your email" |
03dcbf0c1
|
39 40 |
required ></v-text-field> |
7d0816758
|
41 |
<label class="title">Password</label> |
03dcbf0c1
|
42 |
<v-text-field |
af414ec9c
|
43 |
style="padding: 0px; margin: 0px;" |
e3e2a04c6
|
44 |
:rules="[rules.required]" |
96f88269a
|
45 |
v-model.trim="userLogincredentials.password" |
03dcbf0c1
|
46 47 48 49 |
:append-icon="e1 ? 'visibility_off' : 'visibility'" :append-icon-cb="() => (e1 = !e1)" :type="e1 ? 'password' : 'text'" name="input-10-1" |
7d0816758
|
50 |
placeholder="Enter Your password" |
654e1501d
|
51 |
@keyup.enter="login" |
03dcbf0c1
|
52 53 |
></v-text-field> </v-form> |
9b444e5c3
|
54 55 |
<v-layout> <v-flex xs12 class="pa-0 ma-0"> |
a17c68a03
|
56 |
<h5 class="right mt-4"> |
7d0816758
|
57 |
<router-link class="link" to="/forgetpassword">Forgot password</router-link> |
a17c68a03
|
58 59 60 |
</h5> </v-flex> </v-layout> |
93a68cfa1
|
61 |
</v-flex> |
03dcbf0c1
|
62 63 |
</v-card-text> <v-layout> |
9b444e5c3
|
64 |
<v-flex sm12> |
a17c68a03
|
65 |
<v-btn |
7d0816758
|
66 |
style="margin: auto;display: block;background-color: #71d9ea; color: #0c0754;" |
a17c68a03
|
67 |
dark |
7d0816758
|
68 |
flat |
a17c68a03
|
69 70 71 72 |
@click="login" :loading="loading" >Login</v-btn> </v-flex> |
c7a4fe86a
|
73 |
</v-layout> |
a17c68a03
|
74 |
<v-layout></v-layout> |
93a68cfa1
|
75 76 77 78 79 |
</v-card> </v-flex> </v-layout> </v-container> </v-content> |
03dcbf0c1
|
80 |
</v-app> |
93a68cfa1
|
81 82 83 |
</template> <script> |
03dcbf0c1
|
84 |
import http from "@/Services/http.js"; |
93a68cfa1
|
85 |
export default { |
03dcbf0c1
|
86 |
data() { |
93a68cfa1
|
87 |
return { |
03dcbf0c1
|
88 89 90 91 92 93 |
snackbar: false, y: "top", x: "right", mode: "", timeout: 3000, text: "", |
080d88547
|
94 |
append: "", |
93a68cfa1
|
95 96 97 98 |
e1: true, loading: false, remember: false, valid: false, |
b34ed827a
|
99 |
userLogincredentials: {}, |
a17c68a03
|
100 |
nameRules: [v => !!v || "Username is required"], |
03dcbf0c1
|
101 |
password: "", |
a17c68a03
|
102 |
email: "", |
07095d4d8
|
103 |
rules: { |
a17c68a03
|
104 |
required: value => !!value || "password is Required." |
03dcbf0c1
|
105 |
} |
93a68cfa1
|
106 107 108 |
}; }, methods: { |
03dcbf0c1
|
109 |
login() { |
229463bd5
|
110 111 112 113 114 115 116 117 118 119 |
if (this.$refs.form.validate()) { this.loading = true; var userdata = { email: this.userLogincredentials.email, password: this.userLogincredentials.password }; http() .post("/schoolLogin", userdata) .then(response => { // console.log("token",response.data.data); |
1571e40b5
|
120 |
this.loading = false; |
229463bd5
|
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
if (response.data.data.role === "ADMIN") { this.$store.dispatch("setToken", response.data.data.token); this.$store.dispatch("Id", response.data.data.id); this.$store.dispatch("Role", response.data.data.role); this.$router.push("/dashboard"); } else if (response.data.data.role === "SUPERADMIN") { this.$store.dispatch("setSchoolRole", response.data.data.role); this.$store.dispatch("setSchoolToken", response.data.data.token); this.$router.push("/schooldashboard"); } else if (response.data.data.role === "TEACHER") { // console.log("teacher", response.data.data.role); this.$store.dispatch("setToken", response.data.data.token); this.$store.dispatch("Id", response.data.data.id); this.$store.dispatch("Role", response.data.data.role); this.$router.push("/dashboard"); } else if (response.data.data.role === "LIBRARIAN") { this.$store.dispatch("setToken", response.data.data.token); this.$store.dispatch("Id", response.data.data.id); this.$store.dispatch("Role", response.data.data.role); this.$router.push("/dashboard"); } else if (response.data.data.role === "ACCOUNTANT") { this.$store.dispatch("setToken", response.data.data.token); this.$store.dispatch("Id", response.data.data.id); this.$store.dispatch("Role", response.data.data.role); this.$router.push("/dashboard"); } }) .catch(error => { if (error.response.data.message) { this.text = error.response.data.message; this.snackbar = true; this.loading = false; } else { this.text = "Server appears to be offline"; this.snackbar = true; this.loading = false; } }); } |
03dcbf0c1
|
160 161 |
} }, |
a17c68a03
|
162 |
mounted() { |
ff30cbe86
|
163 164 |
if (this.$store.state.isUserLoggedIn == true) { this.$router.push("/dashboard"); |
9b444e5c3
|
165 |
} else if (this.$store.state.isSchoolLoggedIn == true) { |
ff30cbe86
|
166 167 |
this.$router.push("/dashboard"); } |
a17c68a03
|
168 |
}, |
03dcbf0c1
|
169 170 171 |
computed: { color() { return this.loading ? "success" : "error"; |
4413a8d93
|
172 |
} |
93a68cfa1
|
173 174 |
} }; |
93a68cfa1
|
175 176 177 |
</script> <style scoped lang="css"> |
03dcbf0c1
|
178 179 180 181 182 183 184 185 |
#login { width: 100%; position: absolute; top: 0; left: 0; content: ""; z-index: 0; } |
93a68cfa1
|
186 |
</style> |
04e3fbc56
|
187 |
<style scoped> |
7d0816758
|
188 189 190 191 192 |
.schoolLogo { height: 60%; padding-left: 31%; } /* img { |
03dcbf0c1
|
193 194 |
position: absolute; top: 13px; |
55f72b7d7
|
195 |
left: 8px; |
7d0816758
|
196 |
} */ |
04e3fbc56
|
197 |
.v-btn--large { |
03dcbf0c1
|
198 |
padding: 0px 84px; |
93a68cfa1
|
199 |
} |
a17c68a03
|
200 201 |
.link { text-decoration: none; |
04e3fbc56
|
202 |
} |
03dcbf0c1
|
203 |
a { |
7d0816758
|
204 |
color: #fff; |
a17c68a03
|
205 |
} |
03dcbf0c1
|
206 |
.mt-4 { |
a17c68a03
|
207 |
margin-top: 21px !important; |
03dcbf0c1
|
208 |
} |
9b444e5c3
|
209 210 211 |
.logo { display: block; } |
03dcbf0c1
|
212 |
@media screen and (max-width: 600px) { |
a17c68a03
|
213 214 215 216 217 |
img { left: 10px; height: 34px; width: 120px; } |
7d0816758
|
218 219 220 221 |
.logo { height: 56px; left: 10px; width: 120px; |
9b444e5c3
|
222 |
display: block; |
a17c68a03
|
223 |
} |
7d0816758
|
224 225 226 227 |
.logoSchool { height: 87px; left: 10px; width: 120px; |
a17c68a03
|
228 |
} |
4413a8d93
|
229 |
} |
93a68cfa1
|
230 |
</style> |