better email login

This commit is contained in:
2022-11-20 19:06:55 +08:00
parent b156368dc7
commit 4cc7688f41
3 changed files with 44 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -334,3 +334,7 @@ a.button {
padding: 5px; padding: 5px;
} }
.li-image {
width: 100%;
}

View File

@@ -8,6 +8,7 @@ import copy from 'copy-to-clipboard';
import './global.css'; import './global.css';
import './widgets.css'; import './widgets.css';
import emailExample from '../images/email_example.jpg';
import { get_json, API_VERSION_PARAM } from './functions'; import { get_json, API_VERSION_PARAM } from './functions';
import { EMAIL } from '../UserAction'; import { EMAIL } from '../UserAction';
@@ -68,6 +69,7 @@ class LoginPopupSelf extends Component {
super(props); super(props);
this.state = { this.state = {
token_phrase: '', token_phrase: '',
already_copy: false,
}; };
} }
@@ -86,6 +88,17 @@ class LoginPopupSelf extends Component {
sha256_hex(token_phrase + 'hole' + new Date().toDateString(), 16) sha256_hex(token_phrase + 'hole' + new Date().toDateString(), 16)
.then((token) => sha256_hex(token + 'hole', 16)) .then((token) => sha256_hex(token + 'hole', 16))
.then((token_hash) => copy('|' + token_hash + '|')); .then((token_hash) => copy('|' + token_hash + '|'));
this.setState({already_copy: true});
}
copy_token_phrase(event) {
const { token_phrase } = this.state;
if (!token_phrase) {
alert('不可以为空');
return;
}
copy(token_phrase);
} }
use_token(event) { use_token(event) {
@@ -103,7 +116,7 @@ class LoginPopupSelf extends Component {
} }
render() { render() {
const { token_phrase } = this.state; const { token_phrase, already_copy } = this.state;
return ( return (
<div> <div>
<div className="thuhole-login-popup-shadow" /> <div className="thuhole-login-popup-shadow" />
@@ -115,22 +128,36 @@ class LoginPopupSelf extends Component {
<div className="thuhole-login-popup-info"> <div className="thuhole-login-popup-info">
<ol> <ol>
<li> <li>
输入任意<b>独特</b> <a href="###" onClick={() => this.setState({token_phrase: window.crypto.randomUUID(), already_copy: false})}>
<a href="###" onClick={() => this.setState({token_phrase: window.crypto.randomUUID()})}> 生成
使用随机值
</a> </a>
生成token请务必保存好输入的内容并避免泄漏 或粘贴用来生成token的ID
</li> </li>
<li> {!!token_phrase && (
<a href="###" onClick={this.copy_token_hash.bind(this)}><b>点击此处</b></a> <li>
复制token的哈希通过<b>你的清华邮箱</b> <a href="###" onClick={this.copy_token_phrase.bind(this)}><b>点击此处</b></a>
<a href={'mailto:' + EMAIL}>{EMAIL}</a> 复制此ID用于在其他设备上登录当日有效注意妥善保管
</li> </li>
<li> )}
{!!token_phrase && (
<li>
<a href="###" onClick={this.copy_token_hash.bind(this)}><b>点击此处</b></a>
复制用来发送邮件的内容
</li>
)}
{!!already_copy ? (
<li>
发送邮件到
<a href={'mailto:' + EMAIL}>{EMAIL}</a>
不同设备请勿重复发件
后台每15分钟查收一次邮件等待一段时间后 后台每15分钟查收一次邮件等待一段时间后
<a href="###" onClick={this.use_token.bind(this)}><b>点击此处</b></a> <a href="###" onClick={this.use_token.bind(this)}><b>点击此处</b></a>
使用此token登 使用此token登示例:
</li> <img src={emailExample} className="li-image"/>
</li>
) : (
<li>...</li>
)}
</ol> </ol>
</div> </div>
<br /> <br />