add login instruction
This commit is contained in:
14
src/App.js
14
src/App.js
@@ -82,14 +82,20 @@ class App extends Component {
|
||||
<TokenCtx.Consumer>{(token)=>(
|
||||
<div className="left-container">
|
||||
<DeprecatedAlert token={token.value} />
|
||||
{!token.value &&
|
||||
<div className="flow-item-row aux-margin">
|
||||
<div className="box box-tip">
|
||||
<p>点击右上角的 <span className="icon icon-login" /> 按钮登录</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
{this.inpku_flag||token.value ?
|
||||
<Flow key={this.state.flow_render_key} show_sidebar={this.show_sidebar_bound}
|
||||
mode={this.state.mode} search_text={this.state.search_text} token={token.value}
|
||||
/> :
|
||||
<div className="flow-item-row">
|
||||
<div className="box box-tip aux-margin">
|
||||
<p>本网站仅限校内用户使用</p>
|
||||
<p>请点击右上角的 <span className="icon icon-login" /> 按钮登录</p>
|
||||
<div className="flow-item-row aux-margin">
|
||||
<div className="box box-tip">
|
||||
<p>本网站仅限校内用户使用,请登录后访问。</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class ControlBar extends PureComponent {
|
||||
/>
|
||||
<a className="control-btn" onClick={()=>{
|
||||
this.props.show_sidebar(
|
||||
'P大树洞 网页版',
|
||||
'P大树洞',
|
||||
<div>
|
||||
<PromotionBar />
|
||||
<LoginForm show_sidebar={this.props.show_sidebar} />
|
||||
|
||||
@@ -35,6 +35,9 @@ export class LoginForm extends Component {
|
||||
if(this.state.loading_status==='loading')
|
||||
return;
|
||||
|
||||
this.setState({
|
||||
loading_status: 'loading',
|
||||
},()=>{
|
||||
let param=
|
||||
'user='+this.username_ref.current.value+
|
||||
'&svcId='+ISOP_SVCID+
|
||||
@@ -42,11 +45,29 @@ export class LoginForm extends Component {
|
||||
'×tamp='+(+new Date());
|
||||
|
||||
fetch(
|
||||
'https://isop.pku.edu.cn/svcpub/svc/oauth/validcode?'+param+
|
||||
PKUHELPER_ROOT+'isop_proxy/validcode?'+param+
|
||||
'&msg='+md5(param+ISOP_APPCODE),
|
||||
{mode: 'no-cors'}
|
||||
);
|
||||
alert('如果学号存在,短信验证码将会发到您的手机上,请注意查收!');
|
||||
)
|
||||
.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('发送失败。'+e);
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
do_login(set_token) {
|
||||
@@ -82,11 +103,11 @@ export class LoginForm extends Component {
|
||||
});
|
||||
})
|
||||
.catch((e)=>{
|
||||
console.error(e);
|
||||
alert('登录失败');
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
});
|
||||
console.error(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ import './index.css';
|
||||
import App from './App';
|
||||
//import registerServiceWorker from './registerServiceWorker';
|
||||
|
||||
if(window.location.search.indexOf('user_token=')!==-1)
|
||||
window.history.replaceState({},'?','?');
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
//registerServiceWorker();
|
||||
if(navigator.serviceWorker && navigator.serviceWorker.getRegistrations)
|
||||
|
||||
Submodule src/infrastructure updated: 044721854a...90ddcb4646
Reference in New Issue
Block a user