Blame view

src/pages/Authentication/Login.vue 6.4 KB
93a68cfa1   Jatinder Singh   first commit
1
  <template>
03dcbf0c1   Neeraj Sharma   fix all api and r...
2
    <v-app id="login">
a17c68a03   Neeraj Sharma   implement two rou...
3
      <v-toolbar class="fixcolors">
93a68cfa1   Jatinder Singh   first commit
4
        <v-toolbar-items>
88670bfb5   Neeraj Sharma   fixed logo on header
5
          <img src="/static/logoIntrack.png" height="40" width="140" alt="logo" />
654e1501d   Neeraj Sharma   remove school-man...
6
          <!-- <h3 class="white--text my-3 ml-5 logoSchool">School-Management</h3> -->
03dcbf0c1   Neeraj Sharma   fix all api and r...
7
8
        </v-toolbar-items>
      </v-toolbar>
93a68cfa1   Jatinder Singh   first commit
9
10
      <v-content>
        <v-container fluid fill-height>
03dcbf0c1   Neeraj Sharma   fix all api and r...
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   Jatinder Singh   first commit
19
          <v-layout align-center justify-center>
03dcbf0c1   Neeraj Sharma   fix all api and r...
20
            <v-flex xs12 sm10 md6 lg4>
506be6fd7   Neeraj Sharma   implemet dyamic i...
21
              <v-toolbar class="fixcolors" dark>
03dcbf0c1   Neeraj Sharma   fix all api and r...
22
                <v-spacer></v-spacer>
e3e2a04c6   Neeraj Sharma   first commit
23
                <v-toolbar-title>School Login</v-toolbar-title>
03dcbf0c1   Neeraj Sharma   fix all api and r...
24
25
                <v-spacer></v-spacer>
              </v-toolbar>
04e3fbc56   Jatinder Singh   minor fix
26
              <v-card class="elevation-1 pa-1">
03dcbf0c1   Neeraj Sharma   fix all api and r...
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   Neeraj Sharma   implement Student...
31
                        v-model.trim="userLogincredentials.email"
03dcbf0c1   Neeraj Sharma   fix all api and r...
32
33
34
35
36
                        :rules="nameRules"
                        label="Username"
                        required
                      ></v-text-field>
                      <v-text-field
e3e2a04c6   Neeraj Sharma   first commit
37
                        :rules="[rules.required]"
96f88269a   Neeraj Sharma   implement Student...
38
                        v-model.trim="userLogincredentials.password"
03dcbf0c1   Neeraj Sharma   fix all api and r...
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   Neeraj Sharma   remove school-man...
44
                        @keyup.enter="login"
03dcbf0c1   Neeraj Sharma   fix all api and r...
45
46
47
                        counter
                      ></v-text-field>
                    </v-form>
a17c68a03   Neeraj Sharma   implement two rou...
48
49
                    <v-layout row wrap>
                      <v-flex xs6>
603a06702   Neeraj Sharma   implemented chang...
50
                        <!-- <v-checkbox :label="`Remember me`" v-model="remember"></v-checkbox> -->
03dcbf0c1   Neeraj Sharma   fix all api and r...
51
52
                      </v-flex>
                      <v-flex xs6>
a17c68a03   Neeraj Sharma   implement two rou...
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   Jatinder Singh   first commit
62
                  </v-flex>
03dcbf0c1   Neeraj Sharma   fix all api and r...
63
64
                </v-card-text>
                <v-layout>
a17c68a03   Neeraj Sharma   implement two rou...
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   Neeraj Sharma   responsive admin ...
76
                </v-layout>
a17c68a03   Neeraj Sharma   implement two rou...
77
                <v-layout></v-layout>
93a68cfa1   Jatinder Singh   first commit
78
79
80
81
82
              </v-card>
            </v-flex>
          </v-layout>
        </v-container>
      </v-content>
506be6fd7   Neeraj Sharma   implemet dyamic i...
83
      <v-footer class="pa-4 fixcolors"></v-footer>
03dcbf0c1   Neeraj Sharma   fix all api and r...
84
    </v-app>
93a68cfa1   Jatinder Singh   first commit
85
86
87
  </template>
  
  <script>
03dcbf0c1   Neeraj Sharma   fix all api and r...
88
  import http from "@/Services/http.js";
93a68cfa1   Jatinder Singh   first commit
89
  export default {
03dcbf0c1   Neeraj Sharma   fix all api and r...
90
    data() {
93a68cfa1   Jatinder Singh   first commit
91
      return {
03dcbf0c1   Neeraj Sharma   fix all api and r...
92
93
94
95
96
97
        snackbar: false,
        y: "top",
        x: "right",
        mode: "",
        timeout: 3000,
        text: "",
93a68cfa1   Jatinder Singh   first commit
98
99
100
101
        e1: true,
        loading: false,
        remember: false,
        valid: false,
b34ed827a   Jatinder Singh   changes
102
        userLogincredentials: {},
a17c68a03   Neeraj Sharma   implement two rou...
103
        nameRules: [v => !!v || "Username is required"],
03dcbf0c1   Neeraj Sharma   fix all api and r...
104
        password: "",
a17c68a03   Neeraj Sharma   implement two rou...
105
        email: "",
07095d4d8   Jatinder Singh   regex
106
        rules: {
a17c68a03   Neeraj Sharma   implement two rou...
107
          required: value => !!value || "password is Required."
03dcbf0c1   Neeraj Sharma   fix all api and r...
108
        }
93a68cfa1   Jatinder Singh   first commit
109
110
111
      };
    },
    methods: {
03dcbf0c1   Neeraj Sharma   fix all api and r...
112
      login() {
a17c68a03   Neeraj Sharma   implement two rou...
113
        this.loading = true;
e173bab21   Jatinder Singh   api
114
        var userdata = {
e3e2a04c6   Neeraj Sharma   first commit
115
          email: this.userLogincredentials.email,
99cd79184   Neeraj Sharma   implement all tas...
116
          password: this.userLogincredentials.password
03dcbf0c1   Neeraj Sharma   fix all api and r...
117
118
        };
        http()
e3e2a04c6   Neeraj Sharma   first commit
119
          .post("/schoolLogin", userdata)
e173bab21   Jatinder Singh   api
120
          .then(response => {
55f72b7d7   Neeraj Sharma   add new page are ...
121
            this.loading = false;
68d742034   Neeraj Sharma   implement new des...
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   Neeraj Sharma   implement school ...
126
              this.$router.push("/dashboard");
68d742034   Neeraj Sharma   implement new des...
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   Neeraj Sharma   implement school ...
130
              this.$router.push("/school");
68d742034   Neeraj Sharma   implement new des...
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   Neeraj Sharma   implement all tas...
135
              this.$router.push("/libraryMember");
68d742034   Neeraj Sharma   implement new des...
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   Neeraj Sharma   implement all tas...
140
              this.$router.push("/feeTypes");
37150e7c1   Neeraj Sharma   implement school ...
141
            }
03dcbf0c1   Neeraj Sharma   fix all api and r...
142
          })
55f72b7d7   Neeraj Sharma   add new page are ...
143
          .catch(error => {
a17c68a03   Neeraj Sharma   implement two rou...
144
145
146
            if (error) {
              this.text = "Server appears to be offline";
              this.snackbar = true;
1571e40b5   Neeraj Sharma   gallery and socia...
147
              this.loading = false;
a17c68a03   Neeraj Sharma   implement two rou...
148
149
150
151
152
            }
            if (error.response.data.message) {
              this.text = error.response.data.message;
              this.snackbar = true;
            }
03dcbf0c1   Neeraj Sharma   fix all api and r...
153
154
155
156
            this.loading = false;
          });
      }
    },
a17c68a03   Neeraj Sharma   implement two rou...
157
158
    mounted() {
      if (this.$store.state.isUserLoggedIn == true) {
be1fe29bb   Neeraj Sharma   implement number ...
159
        this.$router.push("/dashboard");
68d742034   Neeraj Sharma   implement new des...
160
161
162
163
      } 
      // else if (this.$store.state.isSchoolLoggedIn == true) {
      //   this.$router.push("/school");
      // }
a17c68a03   Neeraj Sharma   implement two rou...
164
    },
03dcbf0c1   Neeraj Sharma   fix all api and r...
165
166
167
    computed: {
      color() {
        return this.loading ? "success" : "error";
4413a8d93   Jatinder Singh   changes
168
      }
93a68cfa1   Jatinder Singh   first commit
169
170
    }
  };
93a68cfa1   Jatinder Singh   first commit
171
172
173
  </script>
  
  <style scoped lang="css">
03dcbf0c1   Neeraj Sharma   fix all api and r...
174
175
176
177
178
179
180
181
  #login {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    content: "";
    z-index: 0;
  }
93a68cfa1   Jatinder Singh   first commit
182
  </style>
04e3fbc56   Jatinder Singh   minor fix
183
  <style scoped>
03dcbf0c1   Neeraj Sharma   fix all api and r...
184
185
186
  img {
    position: absolute;
    top: 13px;
55f72b7d7   Neeraj Sharma   add new page are ...
187
    left: 8px;
04e3fbc56   Jatinder Singh   minor fix
188
189
  }
  .v-btn--large {
03dcbf0c1   Neeraj Sharma   fix all api and r...
190
    padding: 0px 84px;
93a68cfa1   Jatinder Singh   first commit
191
  }
a17c68a03   Neeraj Sharma   implement two rou...
192
193
  .link {
    text-decoration: none;
04e3fbc56   Jatinder Singh   minor fix
194
  }
03dcbf0c1   Neeraj Sharma   fix all api and r...
195
196
197
  a {
    color: #696969;
  }
a17c68a03   Neeraj Sharma   implement two rou...
198
199
200
  .forget {
    margin-top: 20px;
  }
03dcbf0c1   Neeraj Sharma   fix all api and r...
201
  .mt-4 {
a17c68a03   Neeraj Sharma   implement two rou...
202
    margin-top: 21px !important;
03dcbf0c1   Neeraj Sharma   fix all api and r...
203
204
  }
  @media screen and (max-width: 600px) {
a17c68a03   Neeraj Sharma   implement two rou...
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   Neeraj Sharma   add new page are ...
219
      font-size: 14px !important;
a17c68a03   Neeraj Sharma   implement two rou...
220
    }
4413a8d93   Jatinder Singh   changes
221
  }
93a68cfa1   Jatinder Singh   first commit
222
  </style>