From 3f67d8541ff37bc6474720812dd771f10bf2aaf2 Mon Sep 17 00:00:00 2001 From: Steven Hammerton Date: Thu, 8 Oct 2015 22:25:33 +0100 Subject: [PATCH] Add support for CAS login --- src/controllers/pages/MatrixChat.js | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js index d1e289c9cc..f92fe51ce2 100644 --- a/src/controllers/pages/MatrixChat.js +++ b/src/controllers/pages/MatrixChat.js @@ -126,6 +126,31 @@ module.exports = { screen: 'login' }); this.notifyNewScreen('login'); + break; + case 'cas_login': + if (this.state.logged_in) return; + + var self = this; + var client = MatrixClientPeg.get(); + var splitLocation = window.location.href.split('/'); + var serviceUrl = splitLocation[0] + "//" + splitLocation[2]; + + client.loginWithCas(payload.params.ticket, serviceUrl).done(function(data) { + MatrixClientPeg.replaceUsingAccessToken( + client.getHsUrl(), client.getIsUrl(), + data.user_id, data.access_token + ); + self.setState({ + screen: undefined, + logged_in: true + }); + self.startMatrixClient(); + self.notifyNewScreen(''); + }, function(error) { + self.notifyNewScreen('login'); + self.setState({errorText: 'Login failed.'}); + }); + break; case 'view_room': this.focusComposer = true; @@ -314,6 +339,11 @@ module.exports = { action: 'start_login', params: params }); + } else if (screen == 'cas_login') { + dis.dispatch({ + action: 'cas_login', + params: params + }); } else if (screen.indexOf('room/') == 0) { var roomString = screen.split('/')[1]; if (roomString[0] == '#') {