Skip to content

Commit

Permalink
Themed auth0 lock. Added account page with password reset control. Cl…
Browse files Browse the repository at this point in the history
…oses #23
  • Loading branch information
drimpact committed Jul 23, 2017
1 parent 9b282c4 commit 5b93b28
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/app/components/Auth0Lock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const appConfig = require('../../../../config/main');
import * as React from 'react';
import auth0Lock from 'auth0-lock';
import {saveAuth} from 'helpers/auth';
import './style.less';

let count = 0;

Expand Down Expand Up @@ -36,6 +37,9 @@ class Auth0Lock extends React.Component<IProps, {}> {
scope: appConfig.app.auth.scope,
},
},
theme: {
primaryColor: '#935D8C',
},
});
this.lock = new auth0Lock(appConfig.app.auth.clientID, appConfig.app.auth.domain, options);
this.lock.show();
Expand All @@ -57,7 +61,7 @@ class Auth0Lock extends React.Component<IProps, {}> {

public render() {
return (
<div id={this.divID} />
<div id={this.divID} className="impact-auth0-lock" />
);
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/app/components/Auth0Lock/style.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.impact-auth0-lock {
.auth0-lock-header-avatar {
display: none !important;
}
.auth0-lock-header {
display: none !important;
}
}
53 changes: 53 additions & 0 deletions src/app/containers/Account/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import * as React from 'react';
import { Grid } from 'semantic-ui-react';
import {Auth0Lock} from 'components/Auth0Lock';

interface IState {
changePasswordStarted: boolean;
}

class Account extends React.Component<any, IState> {

constructor(props) {
super(props);
this.state = {
changePasswordStarted: false,
};
this.startChangePassword = this.startChangePassword.bind(this);
this.renderChangePassword = this.renderChangePassword.bind(this);
}

private startChangePassword() {
this.setState({
changePasswordStarted: true,
});
}

private renderChangePassword() {
if (this.state.changePasswordStarted) {
return (
<Auth0Lock auth0Options={{initialScreen: 'forgotPassword'}} />
);
} else {
return (
<a onClick={this.startChangePassword}>Click here to change your password</a>
);
}
}

public render() {
return (
<Grid container columns={1} id="Account">
<Grid.Column>
<h1>Account</h1>
<h3>Change Password</h3>
{this.renderChangePassword()}
<h3>Delete Account</h3>
<p>To delete your account, please send an email to <a href="mailto:support@impactasaurus.org?Subject=DeleteAccount">support@impactasaurus.org</a></p>
</Grid.Column>
</Grid>
);
}
}

export { Account }
3 changes: 2 additions & 1 deletion src/app/containers/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class Settings extends React.Component<IProps, any> {
return (
<div id="settings">
<Menu pointing secondary>
<Menu.Item name="Question Sets" active={this.isSelected('/settings/questions')} onClick={this.handleClick('/settings/questions')} />
<Menu.Item name="Account" active={this.isSelected('/settings/account')} onClick={this.handleClick('/settings/account')} />
<Menu.Item name="Organisation" active={this.isSelected('/settings/organisation')} onClick={this.handleClick('/settings/organisation')} />
<Menu.Item name="Question Sets" active={this.isSelected('/settings/questions')} onClick={this.handleClick('/settings/questions')} />
</Menu>

{this.props.children}
Expand Down
1 change: 1 addition & 0 deletions src/app/containers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export { OutcomeSets } from './OutcomeSets';
export { OutcomeSet } from './OutcomeSet';
export { Meeting } from './Meeting';
export { Organisation } from './Organisation';
export {Account} from './Account';
3 changes: 2 additions & 1 deletion src/app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { IndexRoute, Route } from 'react-router';
import { App, Home, Login, Review, ReviewSelector, Conduct, Settings, OutcomeSets, OutcomeSet, Meeting, Organisation } from 'containers';
import { App, Home, Login, Review, ReviewSelector, Conduct, Settings, OutcomeSets, OutcomeSet, Meeting, Organisation, Account } from 'containers';

export default (
<Route path="/" component={App}>
Expand All @@ -10,6 +10,7 @@ export default (
<Route path=":id" component={Review} />
</Route>
<Route path="settings" component={Settings}>
<Route path="account" component={Account} />
<Route path="organisation" component={Organisation} />
<Route path="questions" component={OutcomeSets} />
<Route path="questions/:id" component={OutcomeSet} />
Expand Down
3 changes: 3 additions & 0 deletions src/app/theme/typo.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
font-size: 1.5em;
font-weight: 300;
}
a {
cursor: pointer;
}
}

0 comments on commit 5b93b28

Please sign in to comment.