|
@@ -5,9 +5,13 @@
|
|
|
import React, { Component } from 'react';
|
|
import React, { Component } from 'react';
|
|
|
import { View, StyleSheet, ScrollView, Image, TextInput, Pressable } from 'react-native';
|
|
import { View, StyleSheet, ScrollView, Image, TextInput, Pressable } from 'react-native';
|
|
|
import apiUser from '../../api/apiUser';
|
|
import apiUser from '../../api/apiUser';
|
|
|
|
|
+import { setAccessToken } from '../../api/http';
|
|
|
import Button from '../../components/Button';
|
|
import Button from '../../components/Button';
|
|
|
import Dialog from '../../components/Dialog';
|
|
import Dialog from '../../components/Dialog';
|
|
|
import { Styles } from '../../components/Toolbar';
|
|
import { Styles } from '../../components/Toolbar';
|
|
|
|
|
+import routeUtil from '../../utils/routeUtil';
|
|
|
|
|
+import { getStorageJsonSync, setStorage, setStorageJson } from '../../utils/storage';
|
|
|
|
|
+import { PageList } from '../Router';
|
|
|
import StrengthView from './StrengthView';
|
|
import StrengthView from './StrengthView';
|
|
|
|
|
|
|
|
export default class ResetPassword extends Component {
|
|
export default class ResetPassword extends Component {
|
|
@@ -27,6 +31,17 @@ export default class ResetPassword extends Component {
|
|
|
password: '',
|
|
password: '',
|
|
|
verificationCode: ''
|
|
verificationCode: ''
|
|
|
}
|
|
}
|
|
|
|
|
+ this.isChange = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ componentDidMount() {
|
|
|
|
|
+ const action = this.props.route?.params?.action ?? "";
|
|
|
|
|
+ if (action == "change") {
|
|
|
|
|
+ this.isChange = true;
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ this.requestLogout();
|
|
|
|
|
+ }, 1000);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
componentWillUnmount() {
|
|
@@ -144,13 +159,33 @@ export default class ResetPassword extends Component {
|
|
|
apiUser.updatePassword(this.formInfo).then(res => {
|
|
apiUser.updatePassword(this.formInfo).then(res => {
|
|
|
Dialog.dismissLoading()
|
|
Dialog.dismissLoading()
|
|
|
toastShort('Reset password successfully');
|
|
toastShort('Reset password successfully');
|
|
|
- goBack();
|
|
|
|
|
|
|
+ if (this.isChange) {
|
|
|
|
|
+ this.requestLogout();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ goBack();
|
|
|
|
|
+ }
|
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
|
Dialog.dismissLoading()
|
|
Dialog.dismissLoading()
|
|
|
toastShort(err);
|
|
toastShort(err);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ async requestLogout() {
|
|
|
|
|
+ const data = await getStorageJsonSync('loginData');
|
|
|
|
|
+ if (data && data.email) {
|
|
|
|
|
+ delete data.password
|
|
|
|
|
+ setStorageJson('loginData', data);
|
|
|
|
|
+ setStorage('RegisterTokenDate', "");
|
|
|
|
|
+ }
|
|
|
|
|
+ global.userInfo = {}
|
|
|
|
|
+ /*this.setState({
|
|
|
|
|
+ isLogin: false,
|
|
|
|
|
+ userInfo: {}
|
|
|
|
|
+ });*/
|
|
|
|
|
+ setAccessToken('');
|
|
|
|
|
+ routeUtil.bridge2Page(PageList.login);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
getStrengthStyle() {
|
|
getStrengthStyle() {
|
|
|
const persent = ((this.StrengthView.maxStrength - this.state.strength) / this.StrengthView.maxStrength) * 100
|
|
const persent = ((this.StrengthView.maxStrength - this.state.strength) / this.StrengthView.maxStrength) * 100
|
|
|
return {
|
|
return {
|