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