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