Blame view

src/pages/Authentication/changepassword.vue 3.99 KB
93a68cfa1   Jatinder Singh   first commit
1
2
  <template>
    <v-app id="login">
8bb178441   Neeraj Sharma   implemnt api in s...
3
4
5
      <v-container fluid fill-height>
        <v-layout>
          <v-flex xs12 sm8 md8 lg5 offset-sm2 offset-lg3 class="mt-5">
603a06702   Neeraj Sharma   implemented chang...
6
            <v-toolbar class="fixcolors mt-5" dark>
8bb178441   Neeraj Sharma   implemnt api in s...
7
8
9
              <v-spacer></v-spacer>
              <v-toolbar-title>Technology Succes</v-toolbar-title>
              <v-spacer></v-spacer>
93a68cfa1   Jatinder Singh   first commit
10
            </v-toolbar>
8bb178441   Neeraj Sharma   implemnt api in s...
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
            <v-card class="elevation-1 pa-3" id="form">
              <v-card-text>
                <v-flex xs12 sm8 md8 lg8 offset-sm2>
                  <v-form class="mt-3">
                    <v-text-field
                      :rules="[rules.required]"
                      v-model="adminChangePasswordcredentials.oldPassword"
                      label="Old Password"
                    ></v-text-field>
                    <v-text-field
                      v-model="adminChangePasswordcredentials.newPassword"
                      :rules="[rules.required]"
                      label="New Password"
                    ></v-text-field>
                  </v-form>
                </v-flex>
              </v-card-text>
              <v-card-actions>
                <v-flex text-xs-center>
                  <v-btn
                    class="mt-3"
                    round
                    color="black"
                    dark
                    large
                    :loading="loading"
                    @click="reset"
                  >Reset Password</v-btn>
                </v-flex>
              </v-card-actions>
              <v-snackbar
                :timeout="timeout"
                :top="y === 'top'"
                :right="x === 'right'"
                :vertical="mode === 'vertical'"
                v-model="snackbar"
                :color="color"
              >{{ text }}</v-snackbar>
            </v-card>
          </v-flex>
        </v-layout>
      </v-container>
93a68cfa1   Jatinder Singh   first commit
53
54
55
    </v-app>
  </template>
  <script>
8bb178441   Neeraj Sharma   implemnt api in s...
56
  import http from "@/Services/http.js";
03dcbf0c1   Neeraj Sharma   fix all api and r...
57

93a68cfa1   Jatinder Singh   first commit
58
  export default {
8bb178441   Neeraj Sharma   implemnt api in s...
59
    data() {
93a68cfa1   Jatinder Singh   first commit
60
      return {
03dcbf0c1   Neeraj Sharma   fix all api and r...
61
        snackbar: false,
8bb178441   Neeraj Sharma   implemnt api in s...
62
63
64
        y: "top",
        x: "right",
        mode: "",
03dcbf0c1   Neeraj Sharma   fix all api and r...
65
        timeout: 4000,
8bb178441   Neeraj Sharma   implemnt api in s...
66
        text: "",
b34ed827a   Jatinder Singh   changes
67
        adminChangePasswordcredentials: {},
04e3fbc56   Jatinder Singh   minor fix
68
69
70
        e1: true,
        e2: true,
        e3: true,
93a68cfa1   Jatinder Singh   first commit
71
72
        loading: false,
        valid: false,
8bb178441   Neeraj Sharma   implemnt api in s...
73
74
75
76
        text: "Password Changed",
        currentPassword: "",
        newPassword: "",
        confirmPassword: "",
04e3fbc56   Jatinder Singh   minor fix
77
        rules: {
860da881d   Shikha Mishra   comment all consoles
78
          required: (value) => !!value || "This password field is Required.",
e3e2a04c6   Neeraj Sharma   first commit
79
          // min: v => (/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/).test(v) && v.length >= 8 || 'Min 8 characters upper case lower case symbol required'
860da881d   Shikha Mishra   comment all consoles
80
        },
93a68cfa1   Jatinder Singh   first commit
81
82
83
      };
    },
    methods: {
8bb178441   Neeraj Sharma   implemnt api in s...
84
      reset() {
03dcbf0c1   Neeraj Sharma   fix all api and r...
85
        var token = this.$store.state.token;
e173bab21   Jatinder Singh   api
86
        var userdata = {
8bb178441   Neeraj Sharma   implemnt api in s...
87
          oldPassword: this.adminChangePasswordcredentials.oldPassword,
860da881d   Shikha Mishra   comment all consoles
88
          newPassword: this.adminChangePasswordcredentials.newPassword,
8bb178441   Neeraj Sharma   implemnt api in s...
89
90
91
        };
        http()
          .put("/schoolChangePassword", userdata, {
860da881d   Shikha Mishra   comment all consoles
92
            headers: { Authorization: "Bearer " + token },
8bb178441   Neeraj Sharma   implemnt api in s...
93
          })
860da881d   Shikha Mishra   comment all consoles
94
          .then((response) => {
03dcbf0c1   Neeraj Sharma   fix all api and r...
95
            this.loading = true;
8bb178441   Neeraj Sharma   implemnt api in s...
96
97
            if ((this.snackbar = true)) {
              this.text = "Successfully changed password !!";
860da881d   Shikha Mishra   comment all consoles
98
              // console.log("snackbar", response.data.message);
8bb178441   Neeraj Sharma   implemnt api in s...
99
100
101
102
103
            }
            setTimeout(() => {
              this.$router.push("/dashboard");
            }, 2000);
          })
860da881d   Shikha Mishra   comment all consoles
104
          .catch((error) => {
03dcbf0c1   Neeraj Sharma   fix all api and r...
105
            // console.log("err====>",err);
8bb178441   Neeraj Sharma   implemnt api in s...
106
107
108
            this.text = "User Not Found or Incorrect currentPassword";
            this.snackbar = true;
            this.loading = false;
00e4bc4e1   Neeraj Sharma   fixed auntentication
109
110
111
112
113
114
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
              this.$store.dispatch("Role", null);
            }
8bb178441   Neeraj Sharma   implemnt api in s...
115
          });
860da881d   Shikha Mishra   comment all consoles
116
      },
03dcbf0c1   Neeraj Sharma   fix all api and r...
117
    },
8bb178441   Neeraj Sharma   implemnt api in s...
118
119
120
    computed: {
      color() {
        return this.loading ? "success" : "error";
860da881d   Shikha Mishra   comment all consoles
121
122
      },
    },
93a68cfa1   Jatinder Singh   first commit
123
124
  };
  </script>
04e3fbc56   Jatinder Singh   minor fix
125
  <style scoped>
8bb178441   Neeraj Sharma   implemnt api in s...
126
127
128
129
  img {
    position: absolute;
    top: 13px;
    left: 50px;
93a68cfa1   Jatinder Singh   first commit
130
  }
04e3fbc56   Jatinder Singh   minor fix
131
  .v-btn--large {
8bb178441   Neeraj Sharma   implemnt api in s...
132
    padding: 0px 74px;
04e3fbc56   Jatinder Singh   minor fix
133
  }
8bb178441   Neeraj Sharma   implemnt api in s...
134
135
  @media screen and (max-width: 769px) {
    .v-btn--large {
f42c1d9c9   Neeraj Sharma   something change ...
136
137
138
      font-size: 14px;
      height: 44px;
      padding: 0 32px;
8bb178441   Neeraj Sharma   implemnt api in s...
139
    }
f42c1d9c9   Neeraj Sharma   something change ...
140
  }
04e3fbc56   Jatinder Singh   minor fix
141
  </style>