-
Notifications
You must be signed in to change notification settings - Fork 6
Pass.muxi tech.xyz auth fix #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| .find-pass { | ||
| margin-left: 100px; | ||
| } | ||
| .focus { | ||
| cursor: pointer; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| import React, { Component } from 'react'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. login 文件夹是老的登陆,login_auth 是新的吗,如果是这样,你在路由里面要给这个组件加一个新的路由啊。不然用户怎么访问。 |
||
| import { Link } from 'react-router-dom'; | ||
| import Notification from 'rc-notification'; | ||
| import 'rc-notification/assets/index.css'; | ||
| import getCookie from '../../common/cookie'; | ||
| import './login.css'; | ||
| import Service from '../../common/service'; | ||
| import Layout from '../../component/layout'; | ||
| import Button from '../../component/common/button/button'; | ||
| import Input from '../../component/common/input/input'; | ||
| import getQueryVariable from '../../common/getFromUrl'; | ||
| class Login_auth extends Component { | ||
| componentDidMount() { | ||
| if (localStorage.getItem('checked')) { | ||
| Service.Login( | ||
| localStorage.getItem('username'), | ||
| localStorage.getItem('password') | ||
| ).then(res => { | ||
| if (res !== null && res !== undefined) { | ||
| this.setState({ | ||
| username: localStorage.getItem('username'), | ||
| password: localStorage.getItem('password') | ||
| }); | ||
| } else { | ||
| this.failed = true; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| constructor(props) { | ||
| super(props); | ||
| this.state = { | ||
| isChecked: false, | ||
| username: '', | ||
| password: '', | ||
| infoPassword: '' | ||
| }; | ||
| } | ||
| changeUsername(e) { | ||
| this.setState({ | ||
| username: e.target.value | ||
| }); | ||
| } | ||
|
|
||
| changePassword(e) { | ||
| let val = e.target.value; | ||
| this.setState({ password: val.substring(0, 20) }); | ||
| } | ||
|
|
||
| changeCheck(e) { | ||
| const { isChecked } = this.state; | ||
| this.setState({ | ||
| isChecked: !isChecked | ||
| }); | ||
| } | ||
|
|
||
| alert(string) { | ||
| Notification.newInstance({}, notification => { | ||
| notification.notice({ | ||
| content: string | ||
| }); | ||
| }); | ||
| } | ||
| async login() { | ||
| const { username, password, isChecked } = this.state; | ||
| let client_id = getQueryVariable('client_id'); | ||
| if (username && password) { | ||
| const res = await Service.getOauthCode(username, password, client_id); | ||
| console.log(res); | ||
| if (res.code === 20102) { | ||
| this.alert('用户不存在'); | ||
| } else if (res.code === 20301) { | ||
| this.alert('密码错误'); | ||
| } else if (res.code === 0) { | ||
| this.alert('登录成功,正在跳转'); | ||
| let accessCode = res.data.code; | ||
| console.log(accessCode); | ||
| //如果用户勾选下次自动登录,保存此次登录信息 | ||
| if (isChecked) { | ||
| localStorage.setItem('username', username); | ||
| localStorage.setItem('password', password); | ||
| localStorage.setItem('checked', isChecked); | ||
| } | ||
| //跳转到工作台 | ||
| let landing = getCookie('landing'); | ||
| window.location.href = | ||
| 'http://' + landing + 'landing/?' + 'accessCode=' + accessCode; | ||
| } | ||
| } else { | ||
| this.alert('请输入用户名和密码'); | ||
| } | ||
| } | ||
| render() { | ||
| const { isChecked, username, password } = this.state; | ||
| return ( | ||
| <div> | ||
| <Layout> | ||
| <div className="sign-in-container"> | ||
| <div className="title"> | ||
| <div className="span1">登录</div> | ||
| <div className="span2"> | ||
| <Link | ||
| to="/register" | ||
| style={{ | ||
| textDecoration: 'none', | ||
| color: 'rgba(145,145,145,1)' | ||
| }} | ||
| > | ||
| 注册 | ||
| </Link> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="input-prepend"> | ||
| <Input | ||
| type="text" | ||
| placeholder="用户名或邮箱" | ||
| value={username} | ||
| onChange={this.changeUsername.bind(this)} | ||
| /> | ||
| </div> | ||
| <div className="input-prepend"> | ||
| <Input | ||
| type="password" | ||
| placeholder="密码" | ||
| value={password} | ||
| onChange={this.changePassword.bind(this)} | ||
| /> | ||
| </div> | ||
| <div className="auto-login-btn"> | ||
| <Input | ||
| type="checkbox" | ||
| value="true" | ||
| checked={isChecked} | ||
| onChange={this.changeCheck.bind(this)} | ||
| name="session[auto-login]" | ||
| className="session-auto-login" | ||
| /> | ||
| <div className="focus" onClick={this.changeCheck.bind(this)}> | ||
| 下次自动登陆 | ||
| </div> | ||
| <div className="find-pass"> | ||
| <Link to="/find_pass" style={{ textDecoration: 'none' }}> | ||
| 找回密码? | ||
| </Link> | ||
| </div> | ||
| </div> | ||
| <Button | ||
| disabled={false} | ||
| type="button" | ||
| btnContent="登录" | ||
| onClick={this.login.bind(this)} | ||
| /> | ||
| </div> | ||
| </Layout> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
| export default Login_auth; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个文件确定恢复到之前的状态了吧?如果不确定可以直接去 Git 历史里找老的文件,复制粘贴