From e1a3f04983ae24a7c0cf3e3683f1f832a70aa07c Mon Sep 17 00:00:00 2001
From: xmcp 点击右上角的 按钮登录
+ 本网站仅限校内用户使用,请登录后访问。
diff --git a/src/UserAction.css b/src/UserAction.css
index 6e2135d4..00b1c637 100644
--- a/src/UserAction.css
+++ b/src/UserAction.css
@@ -2,17 +2,9 @@
margin: 1em 0;
text-align: center;
}
-.login-form input {
- width: 8rem;
-}
.login-form button {
width: 6rem;
}
-.login-type {
- display: inline-block;
- width: 6rem;
- margin: 0 .5rem;
-}
.reply-form {
display: flex;
diff --git a/src/UserAction.js b/src/UserAction.js
index a42f9464..776d17f3 100644
--- a/src/UserAction.js
+++ b/src/UserAction.js
@@ -5,8 +5,7 @@ import {MessageViewer} from './Message';
import {API_VERSION_PARAM, PKUHELPER_ROOT, API, get_json, token_param} from './flows_api';
import './UserAction.css';
-
-const LOGIN_BASE=PKUHELPER_ROOT+'services/login';
+import {LoginPopup} from './infrastructure/widgets';
const BASE64_RATE=4/3;
const MAX_IMG_DIAM=8000;
@@ -73,117 +72,6 @@ class ResetUsertokenWidget extends Component {
}
export class LoginForm extends Component {
- constructor(props) {
- super(props);
- this.state={
- loading_status: 'done',
- };
-
- this.username_ref=React.createRef();
- this.password_ref=React.createRef();
- this.input_token_ref=React.createRef();
- }
-
- do_sendcode(api_name) {
- if(this.state.loading_status==='loading')
- return;
-
- this.setState({
- loading_status: 'loading',
- },()=>{
- fetch(
- PKUHELPER_ROOT+'api_xmcp/isop/'+api_name
- +'?user='+encodeURIComponent(this.username_ref.current.value)
- +API_VERSION_PARAM()
- )
- .then(get_json)
- .then((json)=>{
- console.log(json);
- if(!json.success)
- throw new Error(JSON.stringify(json));
-
- alert(json.msg);
- this.setState({
- loading_status: 'done',
- });
- })
- .catch((e)=>{
- console.error(e);
- alert('发送失败\n'+e);
- this.setState({
- loading_status: 'done',
- });
- });
-
- });
- }
-
- do_login(set_token) {
- if(this.state.loading_status==='loading')
- return;
-
- this.setState({
- loading_status: 'loading',
- },()=>{
- let data=new URLSearchParams();
- data.append('username', this.username_ref.current.value);
- data.append('valid_code', this.password_ref.current.value);
- data.append('isnewloginflow', 'true');
- fetch(LOGIN_BASE+'/login.php?platform=webhole'+API_VERSION_PARAM(), {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- },
- body: data,
- })
- .then(get_json)
- .then((json)=>{
- if(json.code!==0) {
- if(json.msg) throw new Error(json.msg);
- throw new Error(JSON.stringify(json));
- }
-
- set_token(json.user_token);
- alert(`成功以 ${json.name} 的身份登录`);
- this.setState({
- loading_status: 'done',
- });
- })
- .catch((e)=>{
- console.error(e);
- alert('登录失败\n'+e);
- this.setState({
- loading_status: 'done',
- });
- });
- });
- }
-
- do_input_token(set_token) {
- if(this.state.loading_status==='loading')
- return;
-
- let token=this.input_token_ref.current.value;
- this.setState({
- loading_status: 'loading',
- },()=>{
- API.get_attention(token)
- .then((_)=>{
- this.setState({
- loading_status: 'done',
- });
- set_token(token);
- })
- .catch((e)=>{
- alert('Token检验失败\n'+e);
- this.setState({
- loading_status: 'done',
- });
- console.error(e);
- });
- });
- }
-
copy_token(token) {
if(copy(token))
alert('复制成功!\n请一定不要泄露哦');
@@ -217,43 +105,19 @@ export class LoginForm extends Component {
User Token 用于迁移登录状态,切勿告知他人,若怀疑被盗号请尽快
接收验证码来登录 PKU Helper
-- - - this.do_sendcode('validcode')}> - 短信 - - / - this.do_sendcode('validcode2mail')}> - 邮件 - - -
-- - -
-从其他设备导入登录状态
-- - -
-+ +
++ PKU Helper 面向北京大学学生,通过 ISOP(北京大学数据共享开放服务平台)验证您的身份并提供服务。 +
+