diff options
author | JoramWilander <jwawilander@gmail.com> | 2015-09-16 15:49:12 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2015-09-16 15:49:12 -0400 |
commit | 47e6a33a4505e13ba4edf37ff1f8fbdadb279ee3 (patch) | |
tree | 9d798d908b3a76d6e228f39872e74cccfc27ad35 /web/react/components/authorize.jsx | |
parent | 7e418714bce067172e527359f391943459b3bd48 (diff) | |
download | chat-47e6a33a4505e13ba4edf37ff1f8fbdadb279ee3.tar.gz chat-47e6a33a4505e13ba4edf37ff1f8fbdadb279ee3.tar.bz2 chat-47e6a33a4505e13ba4edf37ff1f8fbdadb279ee3.zip |
Implement OAuth2 service provider functionality.
Diffstat (limited to 'web/react/components/authorize.jsx')
-rw-r--r-- | web/react/components/authorize.jsx | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/web/react/components/authorize.jsx b/web/react/components/authorize.jsx new file mode 100644 index 000000000..dd4479ad4 --- /dev/null +++ b/web/react/components/authorize.jsx @@ -0,0 +1,72 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +var Client = require('../utils/client.jsx'); + +export default class Authorize extends React.Component { + constructor(props) { + super(props); + + this.handleAllow = this.handleAllow.bind(this); + this.handleDeny = this.handleDeny.bind(this); + + this.state = {}; + } + handleAllow() { + const responseType = this.props.responseType; + const clientId = this.props.clientId; + const redirectUri = this.props.redirectUri; + const state = this.props.state; + const scope = this.props.scope; + + Client.allowOAuth2(responseType, clientId, redirectUri, state, scope, + (data) => { + if (data.redirect) { + window.location.replace(data.redirect); + } + }, + () => {} + ); + } + handleDeny() { + window.location.replace(this.props.redirectUri + '?error=access_denied'); + } + render() { + return ( + <div className='authorize-box'> + <div className='authorize-inner'> + <h3>{'An application would like to connect to your '}{this.props.teamName}{' account'}</h3> + <label>{'The app '}{this.props.appName}{' would like the ability to access and modify your basic information.'}</label> + <br/> + <br/> + <label>{'Allow '}{this.props.appName}{' access?'}</label> + <br/> + <button + type='submit' + className='btn authorize-btn' + onClick={this.handleDeny} + > + {'Deny'} + </button> + <button + type='submit' + className='btn btn-primary authorize-btn' + onClick={this.handleAllow} + > + {'Allow'} + </button> + </div> + </div> + ); + } +} + +Authorize.propTypes = { + appName: React.PropTypes.string, + teamName: React.PropTypes.string, + responseType: React.PropTypes.string, + clientId: React.PropTypes.string, + redirectUri: React.PropTypes.string, + state: React.PropTypes.string, + scope: React.PropTypes.string +}; |