mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-12 11:21:08 +03:30
send Api Ok
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
<v-app>
|
||||
<!-- <core-filter /> -->
|
||||
|
||||
<core-modal />
|
||||
|
||||
<core-toolbar v-if="loggedIn" />
|
||||
|
||||
<core-drawer v-if="loggedIn" />
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<div>
|
||||
<modal-base :show="getCurrentModal" width="70%" @close="closeModal">
|
||||
<component :is="getCurrentModal" v-bind="getModalProperties"></component>
|
||||
</modal-base>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { mapGetters, mapMutations } from "vuex";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
showModal: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapMutations('modal', [
|
||||
'changeCurrentModal'
|
||||
]),
|
||||
closeModal: function() {
|
||||
this.changeCurrentModal('');
|
||||
},
|
||||
},
|
||||
computed : {
|
||||
...mapGetters('modal',[
|
||||
'getCurrentModal', 'getModalProperties'
|
||||
])
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<transition name="fade">
|
||||
<div class="mng-modal" @click="close" v-show="show">
|
||||
<transition name="slide">
|
||||
<div class="mng-modal-container" :style="{'width':width}" v-if="show" @click.stop>
|
||||
<slot>this is sample content</slot>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: ["show", "width"],
|
||||
methods: {
|
||||
close: function() {
|
||||
this.$emit("close");
|
||||
}
|
||||
},
|
||||
mounted: function() {
|
||||
document.addEventListener("keydown", e => {
|
||||
if (this.show && e.keyCode == 27) {
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.mng-modal {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
position: fixed;
|
||||
overflow-y: auto;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
z-index: 10000001;
|
||||
}
|
||||
|
||||
.mng-modal-container {
|
||||
margin: 30px auto;
|
||||
}
|
||||
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity .15s linear;
|
||||
-webkit-transition: opacity .15s linear;
|
||||
}
|
||||
.fade-enter, .fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.slide-enter,
|
||||
.slide-leave-to {
|
||||
-webkit-transform: translate(0, -35%);
|
||||
-ms-transform: translate(0, -35%);
|
||||
-o-transform: translate(0, -35%);
|
||||
transform: translate(0, -35%);
|
||||
}
|
||||
|
||||
.slide-enter-active,
|
||||
.slide-leave-active {
|
||||
transition: transform .3s ease-out;
|
||||
}
|
||||
|
||||
.slide-enter-to,
|
||||
.slide-leave {
|
||||
-webkit-transform: translate(0, 0);
|
||||
-ms-transform: translate(0, 0);
|
||||
-o-transform: translate(0, 0);
|
||||
transform: translate(0, 0);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<v-form >
|
||||
<v-container grid-list-xs>
|
||||
<v-layout row wrap class="justify-center">
|
||||
<v-flex xs12 md3 sm3 class="WM-WidthScreen-SM WM-WidthScreen-XS">
|
||||
<material-card
|
||||
color="black"
|
||||
title="Verify Code">
|
||||
<v-layout row wrap class="px-3">
|
||||
<v-flex xs12 md12 sm12>
|
||||
<v-text-field
|
||||
v-model="verifyCode"
|
||||
label="Verify Code Number"
|
||||
color="black"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout row wrap class="px-3">
|
||||
<v-flex xs12 md6 sm6 class="text-md-left text-sm-center text-xs-center">
|
||||
<v-btn class="WM-CyanBlueGradient-BG" style="padding:10px 60px" @click="submitVerifyCode">
|
||||
<v-icon class="white--text mr-2 caption">fas fa-sign-in-alt</v-icon>
|
||||
<span class="white--text">Submit</span>
|
||||
</v-btn>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</material-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-container>
|
||||
</v-form>
|
||||
</template>
|
||||
<script>
|
||||
import { mapGetters, mapActions } from "vuex";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
verifyCode: "",
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
...mapActions('auth', [
|
||||
'verifyCodeSMS'
|
||||
]),
|
||||
submitVerifyCode() {
|
||||
if (this.verifyCode != '') {
|
||||
this.verifyCodeSMS({verifyCode: this.verifyCode});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
+11
-5
@@ -1,6 +1,7 @@
|
||||
import axios from 'axios'
|
||||
import { TokenService } from './storage.service'
|
||||
import store from '@/store'
|
||||
import qs from 'qs';
|
||||
|
||||
const ApiService = {
|
||||
|
||||
@@ -44,7 +45,12 @@ const ApiService = {
|
||||
* - password
|
||||
**/
|
||||
customRequest(data) {
|
||||
return axios(data)
|
||||
for (let d in data) {
|
||||
if (typeof data[d] == 'object') {
|
||||
data[d] = qs.stringify(data[d]);
|
||||
}
|
||||
}
|
||||
return axios(data);
|
||||
},
|
||||
|
||||
_401interceptor: null,
|
||||
@@ -56,10 +62,10 @@ const ApiService = {
|
||||
},
|
||||
async (error) => {
|
||||
if (error.request.status == 401) {
|
||||
if (error.config.url.includes('/auth/login/')) {
|
||||
if (error.config.url.includes('auth/login')) {
|
||||
// Refresh token has failed. Logout the user
|
||||
store.dispatch('auth/logout')
|
||||
throw error
|
||||
store.dispatch('auth/logout');
|
||||
throw error;
|
||||
} else {
|
||||
// Refresh the access token
|
||||
try{
|
||||
@@ -90,4 +96,4 @@ const ApiService = {
|
||||
}
|
||||
|
||||
export default ApiService
|
||||
export { ApiService}
|
||||
export { ApiService }
|
||||
|
||||
+31
-3
@@ -21,7 +21,7 @@ const UserService = {
|
||||
login: async function(cell_number, password) {
|
||||
const requestData = {
|
||||
method: 'post',
|
||||
url: "login",
|
||||
url: "/login",
|
||||
data: {
|
||||
cell_number,
|
||||
password,
|
||||
@@ -57,7 +57,7 @@ const UserService = {
|
||||
forgotPassword: async function(cell_number) {
|
||||
const requestData = {
|
||||
method: 'post',
|
||||
url: "/forgotPassword",
|
||||
url: "forgotPassword",
|
||||
data: {
|
||||
cell_number,
|
||||
},
|
||||
@@ -70,7 +70,35 @@ const UserService = {
|
||||
try {
|
||||
const response = await ApiService.customRequest(requestData);
|
||||
ApiService.setHeader();
|
||||
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw new AuthenticationError(error.response.status, error.response.data.detail);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Login the user and store the access token to TokenService.
|
||||
*
|
||||
* @returns access_token
|
||||
* @throws AuthenticationError
|
||||
**/
|
||||
verifyCode: async function(verifyCode) {
|
||||
const requestData = {
|
||||
method: 'post',
|
||||
url: "forgotPassword",
|
||||
data: {
|
||||
verifyCode,
|
||||
},
|
||||
auth: {
|
||||
username: process.env.VUE_APP_CLIENT_ID,
|
||||
password: process.env.VUE_APP_CLIENT_SECRET
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await ApiService.customRequest(requestData);
|
||||
ApiService.setHeader();
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw new AuthenticationError(error.response.status, error.response.data.detail);
|
||||
|
||||
@@ -27,6 +27,11 @@ export default {
|
||||
// TODO: Open Modal For Get Section
|
||||
},
|
||||
|
||||
async verifyCodeSMS({ commit }, {verifyCode}) {
|
||||
const result = await UserService.verifyCode(verifyCode);
|
||||
// TODO: Open Modal For Get Section
|
||||
},
|
||||
|
||||
logout({ commit }) {
|
||||
UserService.logout()
|
||||
commit('logoutSuccess')
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
export default {
|
||||
getCurrentModal: (state) => {
|
||||
return state.currentModal.name
|
||||
},
|
||||
getModalProperties: (state) => {
|
||||
return state.currentModal.properties;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
export default {
|
||||
changeCurrentModal: (state, data) => {
|
||||
state.currentModal.name = data.modal;
|
||||
if (data.properties) {
|
||||
state.currentModal.properties = data.properties;
|
||||
}
|
||||
},
|
||||
closeModal: (state) => {
|
||||
state.currentModal.name = '';
|
||||
state.currentModal.properties = {};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
currentModal: {
|
||||
name: '',
|
||||
properties: {}
|
||||
},
|
||||
}
|
||||
@@ -40,7 +40,7 @@
|
||||
</v-form>
|
||||
</template>
|
||||
<script>
|
||||
import { mapGetters, mapActions } from "vuex";
|
||||
import { mapActions, mapMutations } from "vuex";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -51,11 +51,15 @@ export default {
|
||||
...mapActions('auth', [
|
||||
'forgotPassword'
|
||||
]),
|
||||
...mapMutations('modal', [
|
||||
'changeCurrentModal'
|
||||
]),
|
||||
handleSubmit() {
|
||||
this.changeCurrentModal({modal: 'modal-auth-verify-code'});
|
||||
// Perform a simple validation that cell_number and password have been typed in
|
||||
if (this.cell_number != '') {
|
||||
this.forgotPassword({cell_number: this.cell_number});
|
||||
}
|
||||
// if (this.cell_number != '') {
|
||||
// this.forgotPassword({cell_number: this.cell_number});
|
||||
// }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<router-link class="black--text" to="register">
|
||||
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black">
|
||||
<v-icon class="black--text mr-2 caption">fas fa-plus</v-icon>
|
||||
<span >Register</span>
|
||||
<span class="black--text">Register</span>
|
||||
</v-btn>
|
||||
</router-link>
|
||||
</v-flex>
|
||||
|
||||
Reference in New Issue
Block a user