File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ Copyright 2015 OpenMarket Ltd
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ */
16+
17+ 'use strict' ;
18+
19+ var Url = require ( 'url' ) ;
20+
21+ function getServiceUrl ( ) {
22+ var parsedUrl = Url . parse ( window . location . href ) ;
23+ return parsedUrl . protocol + "//" + parsedUrl . host + parsedUrl . pathname ;
24+ }
25+
26+ module . exports = {
27+ getServiceUrl : getServiceUrl
28+ } ;
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright 2015 OpenMarket Ltd
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ */
16+
17+ 'use strict' ;
18+
19+ var React = require ( "react" ) ;
20+ var MatrixClientPeg = require ( "../../MatrixClientPeg" ) ;
21+ var Cas = require ( "../../CasLogic" ) ;
22+
23+ module . exports = {
24+
25+ onCasClicked : function ( ev ) {
26+ var serviceRedirectUrl = Cas . getServiceUrl ( ) + "#/login/cas" ;
27+ var self = this ;
28+ MatrixClientPeg . get ( ) . getCasServer ( ) . done ( function ( data ) {
29+ var serverUrl = data . serverUrl + "/login?service=" + encodeURIComponent ( serviceRedirectUrl ) ;
30+ window . location . href = serverUrl ;
31+ } , function ( error ) {
32+ self . setStep ( "stage_m.login.cas" ) ;
33+ self . setState ( { errorText : 'Login failed.' } ) ;
34+ } ) ;
35+ } ,
36+
37+ } ;
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ var q = require("q");
2323var sdk = require ( '../../index' ) ;
2424var MatrixTools = require ( '../../MatrixTools' ) ;
2525
26+ var Cas = require ( "../../CasLogic" ) ;
27+
2628module . exports = {
2729 PageTypes : {
2830 RoomView : "room_view" ,
@@ -132,12 +134,11 @@ module.exports = {
132134
133135 var self = this ;
134136 var client = MatrixClientPeg . get ( ) ;
135- var splitLocation = window . location . href . split ( '/' ) ;
136- var serviceUrl = splitLocation [ 0 ] + "//" + splitLocation [ 2 ] ;
137+ var serviceUrl = Cas . getServiceUrl ( ) ;
137138
138139 client . loginWithCas ( payload . params . ticket , serviceUrl ) . done ( function ( data ) {
139140 MatrixClientPeg . replaceUsingAccessToken (
140- client . getHsUrl ( ) , client . getIsUrl ( ) ,
141+ client . getHomeserverUrl ( ) , client . getIdentityServerUrl ( ) ,
141142 data . user_id , data . access_token
142143 ) ;
143144 self . setState ( {
You can’t perform that action at this time.
0 commit comments