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