RN-46 convert loginId to lowercase (#647)

This commit is contained in:
enahum 2017-06-19 16:56:09 -04:00 committed by GitHub
parent c369ca6593
commit f758d69296
4 changed files with 31 additions and 14 deletions

View file

@ -25,21 +25,31 @@ export function handlePasswordChanged(password) {
export function handleSuccessfulLogin() {
return async (dispatch, getState) => {
const {currentUserId} = getState().entities.users;
const token = Client4.getToken();
dispatch({
type: GeneralTypes.RECEIVED_APP_CREDENTIALS,
data: {
url: Client4.getUrl(),
token
token: Client4.getToken()
}
});
}, getState);
const session = await Client4.getSessions(currentUserId, token);
if (Array.isArray(session) && session[0]) {
const s = session[0];
return s.expires_at;
return true;
};
}
export function getSession() {
return async (dispatch, getState) => {
const state = getState();
const {currentUserId} = state.entities.users;
const {credentials} = state.entities.general;
const token = credentials && credentials.token;
if (currentUserId && token) {
const session = await Client4.getSessions(currentUserId, token);
if (Array.isArray(session) && session[0]) {
const s = session[0];
return s.expires_at;
}
}
return false;
@ -49,5 +59,6 @@ export function handleSuccessfulLogin() {
export default {
handleLoginIdChanged,
handlePasswordChanged,
handleSuccessfulLogin
handleSuccessfulLogin,
getSession
};

View file

@ -37,6 +37,7 @@ class Login extends PureComponent {
handleLoginIdChanged: PropTypes.func.isRequired,
handlePasswordChanged: PropTypes.func.isRequired,
handleSuccessfulLogin: PropTypes.func.isRequired,
getSession: PropTypes.func.isRequired,
checkMfa: PropTypes.func.isRequired,
login: PropTypes.func.isRequired
}).isRequired,
@ -64,7 +65,7 @@ class Login extends PureComponent {
componentWillReceiveProps(nextProps) {
if (this.props.loginRequest.status === RequestStatus.STARTED && nextProps.loginRequest.status === RequestStatus.SUCCESS) {
this.props.actions.handleSuccessfulLogin().then(this.goToLoadTeam);
this.props.actions.handleSuccessfulLogin().then(this.props.actions.getSession).then(this.goToLoadTeam);
}
}
@ -193,8 +194,9 @@ class Login extends PureComponent {
};
signIn = () => {
if (this.props.loginRequest.status !== RequestStatus.STARTED) {
this.props.actions.login(this.props.loginId, this.props.password);
const {actions, loginId, loginRequest, password} = this.props;
if (loginRequest.status !== RequestStatus.STARTED) {
actions.login(loginId.toLowerCase(), password);
}
};

View file

@ -4,7 +4,7 @@
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {handleSuccessfulLogin} from 'app/actions/views/login';
import {getSession, handleSuccessfulLogin} from 'app/actions/views/login';
import {getTheme} from 'app/selectors/preferences';
import {setStoreFromLocalData} from 'mattermost-redux/actions/general';
@ -22,6 +22,7 @@ function mapStateToProps(state, ownProps) {
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
getSession,
handleSuccessfulLogin,
setStoreFromLocalData
}, dispatch)

View file

@ -26,6 +26,7 @@ class SSO extends PureComponent {
serverUrl: PropTypes.string.isRequired,
ssoType: PropTypes.string.isRequired,
actions: PropTypes.shape({
getSession: PropTypes.func.isRequired,
handleSuccessfulLogin: PropTypes.func.isRequired,
setStoreFromLocalData: PropTypes.func.isRequired
}).isRequired
@ -94,6 +95,7 @@ class SSO extends PureComponent {
if (token) {
this.setState({renderWebview: false});
const {
getSession,
handleSuccessfulLogin,
setStoreFromLocalData
} = this.props.actions;
@ -101,6 +103,7 @@ class SSO extends PureComponent {
Client4.setToken(token);
setStoreFromLocalData({url: this.props.serverUrl, token}).
then(handleSuccessfulLogin).
then(getSession).
then(this.goToLoadTeam);
}
});