fixed storing loginInfo bug. Other tests

parent bba5be41
...@@ -108,7 +108,7 @@ class OAuthOSTConsumer implements AuthenticationProviderInterface ...@@ -108,7 +108,7 @@ class OAuthOSTConsumer implements AuthenticationProviderInterface
// Only check requests with the 'authorization' header starting with OAuth. // Only check requests with the 'authorization' header starting with OAuth.
// drupal_set_message('sdfsddgdg'); // drupal_set_message('sdfsddgdg');
$oauthEnabled = $this->getHeader($request, 'x-oauth-enabled'); $oauthEnabled = $this->getHeader($request, 'X-oauth-enabled');
if (!$oauthEnabled && $request->getMethod() == 'POST') { if (!$oauthEnabled && $request->getMethod() == 'POST') {
$oauthEnabled = $request->request->get('X-oauth-enabled'); $oauthEnabled = $request->request->get('X-oauth-enabled');
} }
......
import {Router, ActivatedRoute, Params} from '@angular/router'; import {Router, ActivatedRoute, Params} from '@angular/router';
import {OnInit, Component} from '@angular/core'; import {OnInit, Component} from '@angular/core';
import { LoginInfoActions } from '../actions/logininfo.actions'; 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 { import {
FormBuilder, FormBuilder,
FormGroup, FormGroup,
...@@ -9,48 +13,90 @@ import { ...@@ -9,48 +13,90 @@ import {
} from '@angular/forms'; } from '@angular/forms';
import { AppSettings } from '../app.settings'; import { AppSettings } from '../app.settings';
@Component({ @Component({
selector: 'home', selector: 'home',
template: ` template: `
<div> <div>
<h4>Στοιχεία Σύνδεσης</h4>
<form [formGroup]="formGroup" method = "POST" action="http://eepal.dev/drupal/oauth/login" #form> <form [formGroup]="formGroup" method = "POST" action="http://eepal.dev/drupal/oauth/login" #form>
<input type="hidden" name="X-oauth-enabled" value="true"> <input type="hidden" name="X-oauth-enabled" value="true">
<div *ngFor="let loginInfoToken$ of loginInfo$ | async; let i=index">
<div class="row">
<div class="col-md-6">
{{loginInfoToken$.auth_token}}
</div>
<div class="col-md-6">
{{loginInfoToken$.auth_role}}
</div>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-md-2 col-md-offset-5">
<div *ngIf="!authToken" class="col-md-7 col-md-offset-5">
<button type="submit" class="btn-primary btn-lg pull-center" (click)="form.submit()"> <button type="submit" class="btn-primary btn-lg pull-center" (click)="form.submit()">
Είσοδος μέσω TaxisNet<span class="glyphicon glyphicon-menu-right"></span> Είσοδος μέσω TaxisNet<span class="glyphicon glyphicon-menu-right"></span>
</button> </button>
</div> </div>
</div> </div>
<div class="row">
<div *ngIf="authToken" class="col-md-7 col-md-offset-5">
<h3>Καλώς ήρθατε</h3>
</div>
</div>
<div class="row">
<div *ngIf="authToken" class="col-md-7 col-md-offset-5">
<input type="hidden" name="dologout" value="true">
<button type="submit" class="btn-primary btn-lg pull-center" (click)="form.submit()">
Αποσύνδεση<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
</div>
</form> </form>
</div> </div>
` `
}) })
export default class Home implements OnInit{ export default class Home implements OnInit {
public formGroup: FormGroup; public formGroup: FormGroup;
constructor(private fb: FormBuilder, private authToken: string;
private _ata: LoginInfoActions, private authRole: string;
private activatedRoute: ActivatedRoute) { private loginInfo$: Observable<ILoginInfo>;
this.formGroup = this.fb.group({ constructor(private fb: FormBuilder,
private _ata: LoginInfoActions,
private _ngRedux: NgRedux<IAppState>,
private activatedRoute: ActivatedRoute
) {
this.authToken = '';
this.authRole = '';
this.formGroup = this.fb.group({
Username: [], Username: [],
Paswd : [] Paswd: []
}); });
}; };
ngOnInit() { 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) => { this.activatedRoute.queryParams.subscribe((params: Params) => {
let authToken = params['auth_token']; this.authToken = params['auth_token'];
let authRole = params['auth_role']; this.authRole = params['auth_role'];
this._ata.saveLoginInfo({auth_token: authToken, auth_role: authRole}); if (this.authToken && this.authRole)
console.log(authToken); this._ata.saveLoginInfo({ auth_token: this.authToken, auth_role: this.authRole });
// console.log(this.authToken);
}); });
} }
checkvalidation() { checkvalidation() {
}
} }
}
...@@ -10,12 +10,9 @@ export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILo ...@@ -10,12 +10,9 @@ export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILo
switch (action.type) { switch (action.type) {
case LOGININFO_SAVE: case LOGININFO_SAVE:
let loginInfoTokens = Array<ILoginInfoToken>(); let loginInfoTokens = Array<ILoginInfoToken>();
let ind=0; loginInfoTokens.push(<ILoginInfoToken>{auth_token: action.payload.loginInfo.auth_token, auth_role: action.payload.loginInfo.auth_role});
state.forEach(loginInfoToken => {
loginInfoTokens.push(<ILoginInfoToken>{auth_token: action.payload.loginInfo.auth_token, auth_role: action.payload.loginInfo.auth_role});
ind++;
});
return Seq(loginInfoTokens).map(n => n).toList(); return Seq(loginInfoTokens).map(n => n).toList();
default: return state; default:
return state;
} }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment