diff --git a/drupal/modules/oauthost/src/Authentication/Provider/OAuthOSTConsumer.php b/drupal/modules/oauthost/src/Authentication/Provider/OAuthOSTConsumer.php index ba7826adcc00da5ecfe395d07a5b6748d27179b3..6f5c7e07733d8c72a20122ae5180b9a135b4d0a7 100644 --- a/drupal/modules/oauthost/src/Authentication/Provider/OAuthOSTConsumer.php +++ b/drupal/modules/oauthost/src/Authentication/Provider/OAuthOSTConsumer.php @@ -108,7 +108,7 @@ class OAuthOSTConsumer implements AuthenticationProviderInterface // Only check requests with the 'authorization' header starting with OAuth. // drupal_set_message('sdfsddgdg'); - $oauthEnabled = $this->getHeader($request, 'x-oauth-enabled'); + $oauthEnabled = $this->getHeader($request, 'X-oauth-enabled'); if (!$oauthEnabled && $request->getMethod() == 'POST') { $oauthEnabled = $request->request->get('X-oauth-enabled'); } diff --git a/source/components/home.ts b/source/components/home.ts index d8f2da826f449d4aab15d090c0db4d5542292aa7..e475db7cf36e2dccc5432064c3521f3eb0a0fa14 100644 --- a/source/components/home.ts +++ b/source/components/home.ts @@ -1,6 +1,10 @@ import {Router, ActivatedRoute, Params} from '@angular/router'; import {OnInit, Component} from '@angular/core'; import { LoginInfoActions } from '../actions/logininfo.actions'; +import { ILoginInfo } from '../store/logininfo/logininfo.types'; +import { NgRedux, select } from 'ng2-redux'; +import { Observable } from 'rxjs/Rx'; +import { IAppState } from '../store/store'; import { FormBuilder, FormGroup, @@ -9,48 +13,90 @@ import { } from '@angular/forms'; import { AppSettings } from '../app.settings'; @Component({ - selector: 'home', - template: ` + selector: 'home', + template: `
-

Στοιχεία Σύνδεσης

+
+
+
+ {{loginInfoToken$.auth_token}} +
+
+ {{loginInfoToken$.auth_role}} +
+
+
-
+ +
-
+
+
+
+

Καλώς ήρθατε

+
+
+
+
+ + +
+
` }) -export default class Home implements OnInit{ - public formGroup: FormGroup; - constructor(private fb: FormBuilder, - private _ata: LoginInfoActions, - private activatedRoute: ActivatedRoute) { - this.formGroup = this.fb.group({ +export default class Home implements OnInit { + public formGroup: FormGroup; + private authToken: string; + private authRole: string; + private loginInfo$: Observable; + constructor(private fb: FormBuilder, + private _ata: LoginInfoActions, + private _ngRedux: NgRedux, + private activatedRoute: ActivatedRoute + ) { + this.authToken = ''; + this.authRole = ''; + this.formGroup = this.fb.group({ Username: [], - Paswd : [] - }); - }; + Paswd: [] + }); + }; ngOnInit() { - // subscribe to router event + this.loginInfo$ = this._ngRedux.select(state => { + if (state.loginInfo.size > 0) { + state.loginInfo.reduce(({}, loginInfoToken) => { + this.authToken = loginInfoToken.auth_token; + this.authRole = loginInfoToken.auth_role; + return loginInfoToken; + }, {}); + } + return state.loginInfo; + }); + + // subscribe to router event this.activatedRoute.queryParams.subscribe((params: Params) => { - let authToken = params['auth_token']; - let authRole = params['auth_role']; - this._ata.saveLoginInfo({auth_token: authToken, auth_role: authRole}); - console.log(authToken); + this.authToken = params['auth_token']; + this.authRole = params['auth_role']; + if (this.authToken && this.authRole) + this._ata.saveLoginInfo({ auth_token: this.authToken, auth_role: this.authRole }); + // console.log(this.authToken); - }); - } + }); + } - checkvalidation() { + checkvalidation() { - } } +} diff --git a/source/store/logininfo/logininfo.reducer.ts b/source/store/logininfo/logininfo.reducer.ts index c4ecfeb51fd8dd966f80140f0110652e88a2cde1..ecece8449af9a72792b73f8b56ffeac6b538f96c 100644 --- a/source/store/logininfo/logininfo.reducer.ts +++ b/source/store/logininfo/logininfo.reducer.ts @@ -10,12 +10,9 @@ export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILo switch (action.type) { case LOGININFO_SAVE: let loginInfoTokens = Array(); - let ind=0; - state.forEach(loginInfoToken => { - loginInfoTokens.push({auth_token: action.payload.loginInfo.auth_token, auth_role: action.payload.loginInfo.auth_role}); - ind++; - }); + loginInfoTokens.push({auth_token: action.payload.loginInfo.auth_token, auth_role: action.payload.loginInfo.auth_role}); return Seq(loginInfoTokens).map(n => n).toList(); - default: return state; + default: + return state; } };