tomoya il y a 2 ans
Parent
commit
01836b6f5f

+ 1 - 1
frontend/src/App.vue

@@ -10,7 +10,7 @@
 import { RouterView } from "vue-router";
 import { useMainStore } from "@/stores/main";
 import { onMounted } from "vue";
-import LoadingView from "./views/LoadingView.vue";
+import LoadingView from "@/components/Loading.vue";
 import { storeToRefs } from "pinia";
 import NotificationsManager from "@/components/NotificationsManager.vue";
 //store

+ 4 - 4
frontend/src/api.ts

@@ -1,6 +1,6 @@
 import axios from "axios";
 import { apiUrl } from "@/env";
-import type { IUserProfile, IUserProfileUpdate, IUserProfileCreate, IUserProfileRegister } from "@/interfaces";
+import type { IUserProfile, IUserProfileUpdate, IUserProfileCreate} from "@/interfaces";
 
 function authHeaders(token: string) {
   return {
@@ -40,13 +40,13 @@ export const api = {
   async passwordRecovery(email: string) {
     return axios.post(`${apiUrl}/api/v1/password-recovery/${email}`);
   },
-  async resetPassword(password: string, token: string) {
+  async resetPassword(token: string, password: string) {
     return axios.post(`${apiUrl}/api/v1/reset-password/`, {
+      token: token,
       new_password: password,
-      token,
     });
   },
-  async registerUser(data: IUserProfileRegister) {
+  async registerUser(data: IUserProfileCreate) {
     return axios.post(`${apiUrl}/api/v1/users/register`, data);
   },
   async testCeleryMsg(token: string, data:{msg: string}){

+ 0 - 0
frontend/src/views/LoadingView.vue → frontend/src/components/Loading.vue


+ 0 - 5
frontend/src/interfaces/index.ts

@@ -21,8 +21,3 @@ export interface IUserProfileCreate {
     is_active?: boolean;
     is_superuser?: boolean;
 }
-
-export interface IUserProfileRegister {
-    email: string;
-    password: string;
-}

+ 9 - 9
frontend/src/stores/main.ts

@@ -3,7 +3,7 @@ import { defineStore } from "pinia";
 import { api } from "@/api"
 import router from "@/router"
 import { getLocalToken, removeLocalToken, saveLocalToken } from "@/utils";
-import type { IUserProfile, IUserProfileRegister, IUserProfileUpdate } from '@/interfaces';
+import type { IUserProfile, IUserProfileCreate, IUserProfileUpdate } from '@/interfaces';
 
 export interface AppNotification {
   content: string;
@@ -93,13 +93,13 @@ export const useMainStore = defineStore("MainStoreId", {
                 await this.checkApiError(error);
             }
         },  
-        async updateUserProfile(payload: IUserProfileUpdate) {
+        async updateUserProfile(user: IUserProfileUpdate) {
             try {
                 const loadingNotification = { content: "saving", showProgress: true };
                 await this.addNotification(loadingNotification);
                 const response = (
                   await Promise.all([
-                    api.updateMe(this.token, payload),
+                    api.updateMe(this.token, user),
                     await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
                   ])
                 )[0];
@@ -174,7 +174,7 @@ export const useMainStore = defineStore("MainStoreId", {
                 }, payload.timeout);
             });
         },
-        async register(payload: IUserProfileRegister) {
+        async register(user: IUserProfileCreate) {
             const loadingNotification = {
                 content: "Sgining up...",
                 showProgress: true,
@@ -183,7 +183,7 @@ export const useMainStore = defineStore("MainStoreId", {
                 this.addNotification(loadingNotification);
                 const response = (
                   await Promise.all([
-                    api.registerUser(payload),
+                    api.registerUser(user),
                     await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
                   ])
                 )[0];
@@ -196,7 +196,7 @@ export const useMainStore = defineStore("MainStoreId", {
               await this.checkApiError(error);
           }
         },
-        async passwordRecovery(payload: {username: string }) {
+        async passwordRecovery(email: string) {
             const loadingNotification = {
                 content: "Sending password recovery email",
                 showProgress: true,
@@ -204,7 +204,7 @@ export const useMainStore = defineStore("MainStoreId", {
             try {
                 this.addNotification(loadingNotification);
                 await Promise.all([
-                  api.passwordRecovery(payload.username),
+                  api.passwordRecovery(email),
                   await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
                 ]);
                 this.removeNotification(loadingNotification);
@@ -218,12 +218,12 @@ export const useMainStore = defineStore("MainStoreId", {
                 this.addNotification({ color: "error", content: "Incorrect username" });
             }
         },
-        async resetPassword(payload: {password: string; token: string }) {
+        async resetPassword(token: string, password: string ) {
             const loadingNotification = { content: "Resetting password", showProgress: true };
             try {
                 this.addNotification(loadingNotification);
                 await Promise.all([
-                    api.resetPassword(payload.password, payload.token),
+                    api.resetPassword(token, password),
                     await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 500)),
                 ]);
                 this.removeNotification(loadingNotification);

+ 0 - 53
frontend/src/views/Login.vue

@@ -103,57 +103,4 @@ onMounted(() => {});
       </v-col>
     </v-row>
   </v-container>
-
-  <!-- <v-container fluid class="d-flex fill-height">
-    <v-row align="center" justify="center">
-      <v-col :cols="width">
-        <v-card class="elevation-12">
-          <v-toolbar dark color="primary">
-            <v-toolbar-title>{{ appName }}</v-toolbar-title>
-            <v-spacer></v-spacer>
-            <v-btn to="/signup">SignUp</v-btn>
-          </v-toolbar>
-          <v-card-text>
-            <v-form @keyup.enter="submit">
-              <v-text-field
-                @keyup.enter="submit"
-                v-model="email"
-                prepend-icon="person"
-                name="email"
-                label="Email"
-                type="text"
-              ></v-text-field>
-              <v-text-field
-                @keyup.enter="submit"
-                v-model="password"
-                prepend-icon="key"
-                name="password"
-                label="Password"
-                id="password"
-                type="password"
-              ></v-text-field>
-            </v-form>
-            <div v-if="loginError">
-              <v-alert
-                :value="loginError"
-                transition="fade-transition"
-                type="error"
-              >
-                Incorrect email or password
-              </v-alert>
-            </div>
-            <div class="d-flex align-end flex-column">
-              <router-link to="/recover-password"
-                >Forgot your password?</router-link
-              >
-            </div>
-          </v-card-text>
-          <v-card-actions>
-            <v-spacer></v-spacer>
-            <v-btn @click.prevent="submit">Login</v-btn>
-          </v-card-actions>
-        </v-card>
-      </v-col>
-    </v-row>
-  </v-container> -->
 </template>

+ 1 - 1
frontend/src/views/ResetPassword.vue

@@ -86,7 +86,7 @@ async function submit(){
   if (valid.value) {
     const token = checkToken();
     if (token) {
-      await mainStore.resetPassword({token, password: password1.value});
+      await mainStore.resetPassword(token, password1.value);
       router.push('/');
     }
   }

+ 0 - 36
frontend/src/views/Signup.vue

@@ -40,7 +40,6 @@ const width = computed(() => {
 // action
 async function submit() {
   if (confirmPassword.value === data.password) {
-    console.log("data", data.password);
     mainStore.register(data);
   } else {
     confirmState.value = true;
@@ -186,41 +185,6 @@ async function submit() {
       </v-col>
     </v-row>
   </v-container>
-
-  <!-- <v-container fluid class="d-flex fill-height">
-    <v-row align="center" justify="center">
-      <v-col :cols="width">
-        <v-card class="elevation-12">
-          <v-toolbar dark color="primary">
-            <v-toolbar-title>{{ appName }}</v-toolbar-title>
-            <v-spacer></v-spacer>
-            <v-btn to="/login">LogIn</v-btn>
-          </v-toolbar>
-          <v-card-text>
-            <v-form @keyup.enter="submit">
-              <v-text-field
-                @keyup.enter="submit"
-                v-model="email"
-                prepend-icon="person"
-                name="email"
-                label="Email"
-                type="text"
-              ></v-text-field>
-              <v-text-field
-                @keyup.enter="submit"
-                v-model="password"
-                prepend-icon="key"
-                name="password"
-                label="Password"
-                id="password"
-                type="password"
-              ></v-text-field>
-            </v-form>
-          </v-card-text>
-        </v-card>
-      </v-col>
-    </v-row>
-  </v-container> -->
 </template>
 
 <style lang="scss">