1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-10 19:29:56 +00:00

[user settings] rewrote it with react

This commit is contained in:
llj
2019-05-07 14:57:22 +08:00
parent 18aa3f30e9
commit f4725faf0b
18 changed files with 991 additions and 1 deletions

View File

@@ -0,0 +1,52 @@
import React from 'react';
import { gettext, siteRoot } from '../../utils/constants';
const {
defaultDevice,
backupTokens
} = window.app.pageOptions;
class TwoFactorAuthentication extends React.Component {
constructor(props) {
super(props);
}
renderEnabled = () => {
return (
<React.Fragment>
<p className="mb-2">{gettext('Status: enabled')}</p>
<a className="btn btn-secondary mb-4" href={`${siteRoot}profile/two_factor_authentication/disable/`}>
{gettext('Disable Two-Factor Authentication')}</a>
<p className="mb-2">
{gettext('If you don\'t have any device with you, you can access your account using backup codes.')}
{backupTokens == 1 ? gettext('You have only one backup code remaining.') :
gettext('You have {num} backup codes remaining.').replace('{num}', backupTokens)}
</p>
<a href={`${siteRoot}profile/two_factor_authentication/backup/tokens/`}
className="btn btn-secondary">{gettext('Show Codes')}</a>
</React.Fragment>
);
}
renderDisabled = () => {
return (
<React.Fragment>
<p className="mb-2">{gettext('Two-factor authentication is not enabled for your account. Enable two-factor authentication for enhanced account security.')}</p>
<a href={`${siteRoot}profile/two_factor_authentication/setup/`} className="btn btn-secondary">
{gettext('Enable Two-Factor Authentication')}</a>
</React.Fragment>
);
}
render() {
return (
<div className="setting-item" id="two-factor-auth">
<h3 className="setting-item-heading">{gettext('Two-Factor Authentication')}</h3>
{defaultDevice ? this.renderEnabled() : this.renderDisabled()}
</div>
);
}
}
export default TwoFactorAuthentication;