54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
import { encryptPasswordSha1 } from "../../../../utils/password";
|
|
import { maskPassword } from "../../../../utils/user";
|
|
export default OakComponent({
|
|
properties: {
|
|
onVerified: undefined,
|
|
},
|
|
data: {
|
|
input: '',
|
|
mode: 'all',
|
|
},
|
|
lifetimes: {
|
|
async ready() {
|
|
this.features.token.getToken();
|
|
const system = this.features.application.getApplication().system;
|
|
const passwordConfig = system?.config.Password;
|
|
const mode = passwordConfig?.mode ?? 'all';
|
|
this.setState({
|
|
mode,
|
|
});
|
|
}
|
|
},
|
|
features: ['cache'],
|
|
methods: {
|
|
setInput(input) {
|
|
this.setState({ input });
|
|
},
|
|
setDataMp(event) {
|
|
const { detail } = event;
|
|
this.setInput(detail.value);
|
|
},
|
|
async confirm() {
|
|
const { input, mode } = this.state;
|
|
let pwd = input;
|
|
if (mode === 'sha1') {
|
|
pwd = encryptPasswordSha1(input);
|
|
}
|
|
await this.features.token.verifyPassword(pwd);
|
|
const { onVerified } = this.props;
|
|
if (onVerified) {
|
|
onVerified();
|
|
}
|
|
},
|
|
showTips() {
|
|
const user = this.features.token.getUserInfo();
|
|
const { password } = user;
|
|
const content = this.t('tips.content', { password: maskPassword(password), length: password?.length });
|
|
this.setMessage({
|
|
type: 'info',
|
|
content,
|
|
});
|
|
},
|
|
}
|
|
});
|