-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* weixin connect * update
- Loading branch information
Showing
9 changed files
with
238 additions
and
8 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
frontend/src/components/dialog/confirm-disconnect-weixin.js
This file contains 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,45 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap'; | ||
import { gettext } from '../../utils/constants'; | ||
|
||
const propTypes = { | ||
formActionURL: PropTypes.string.isRequired, | ||
csrfToken: PropTypes.string.isRequired, | ||
toggle: PropTypes.func.isRequired | ||
}; | ||
|
||
class ConfirmDisconnectWeixin extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.form = React.createRef(); | ||
} | ||
|
||
disconnect = () => { | ||
this.form.current.submit(); | ||
}; | ||
|
||
render() { | ||
const { formActionURL, csrfToken, toggle } = this.props; | ||
return ( | ||
<Modal centered={true} isOpen={true} toggle={toggle}> | ||
<ModalHeader toggle={toggle}>{gettext('Disconnect')}</ModalHeader> | ||
<ModalBody> | ||
<p>{gettext('Are you sure you want to disconnect?')}</p> | ||
<form ref={this.form} className="d-none" method="post" action={formActionURL}> | ||
<input type="hidden" name="csrfmiddlewaretoken" value={csrfToken} /> | ||
</form> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button color="secondary" onClick={toggle}>{gettext('Cancel')}</Button> | ||
<Button color="primary" onClick={this.disconnect}>{gettext('Disconnect')}</Button> | ||
</ModalFooter> | ||
</Modal> | ||
); | ||
} | ||
} | ||
|
||
ConfirmDisconnectWeixin.propTypes = propTypes; | ||
|
||
export default ConfirmDisconnectWeixin; |
59 changes: 59 additions & 0 deletions
59
frontend/src/components/user-settings/social-login-weixin.js
This file contains 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,59 @@ | ||
import React from 'react'; | ||
import { gettext, siteRoot } from '../../utils/constants'; | ||
import ModalPortal from '../modal-portal'; | ||
import ConfirmDisconnectWeixin from '../dialog/confirm-disconnect-weixin'; | ||
|
||
const { | ||
csrfToken, | ||
langCode, | ||
socialConnectedWeixin, | ||
socialNextPage | ||
} = window.app.pageOptions; | ||
|
||
class SocialLoginWeixin extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
isConfirmDialogOpen: false | ||
}; | ||
} | ||
|
||
confirmDisconnect = () => { | ||
this.setState({ | ||
isConfirmDialogOpen: true | ||
}); | ||
}; | ||
|
||
toggleDialog = () => { | ||
this.setState({ | ||
isConfirmDialogOpen: !this.state.isConfirmDialogOpen | ||
}); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<React.Fragment> | ||
<div className="setting-item" id="social-auth"> | ||
<h3 className="setting-item-heading">{gettext('Social Login')}</h3> | ||
<p className="mb-2">{langCode == 'zh-cn' ? '微信' : 'Weixin'}</p> | ||
{socialConnectedWeixin ? | ||
<button className="btn btn-outline-primary" onClick={this.confirmDisconnect}>{gettext('Disconnect')}</button> : | ||
<a href={`${siteRoot}weixin/oauth-connect/?next=${encodeURIComponent(socialNextPage)}`} className="btn btn-outline-primary">{gettext('Connect')}</a> | ||
} | ||
</div> | ||
{this.state.isConfirmDialogOpen && ( | ||
<ModalPortal> | ||
<ConfirmDisconnectWeixin | ||
formActionURL={`${siteRoot}weixin/oauth-disconnect/?next=${encodeURIComponent(socialNextPage)}`} | ||
csrfToken={csrfToken} | ||
toggle={this.toggleDialog} | ||
/> | ||
</ModalPortal> | ||
)} | ||
</React.Fragment> | ||
); | ||
} | ||
} | ||
|
||
export default SocialLoginWeixin; |
This file contains 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 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 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 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
8 changes: 8 additions & 0 deletions
8
seahub/weixin/templates/weixin/weixin_user_not_found_error.html
This file contains 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,8 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block main_content %} | ||
<div class="text-panel"> | ||
<p class="error">没找到对应的账号,请先用邮箱注册一个团队账号,然后在个人设置页绑定微信后再扫码登录。</p> | ||
<p class="error"><a href="{% url 'org_register' %}">[注册团队账号]</a></p> | ||
</div> | ||
{% endblock %} |
This file contains 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 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