fixed storing loginInfo bug. Other tests

parent bba5be41
......@@ -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');
}
......
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,
......@@ -12,38 +16,80 @@ import { AppSettings } from '../app.settings';
selector: 'home',
template: `
<div>
<h4>Στοιχεία Σύνδεσης</h4>
<form [formGroup]="formGroup" method = "POST" action="http://eepal.dev/drupal/oauth/login" #form>
<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-2 col-md-offset-5">
<div class="col-md-6">
{{loginInfoToken$.auth_token}}
</div>
<div class="col-md-6">
{{loginInfoToken$.auth_role}}
</div>
</div>
</div>
<div class="row">
<div *ngIf="!authToken" class="col-md-7 col-md-offset-5">
<button type="submit" class="btn-primary btn-lg pull-center" (click)="form.submit()">
Είσοδος μέσω TaxisNet<span class="glyphicon glyphicon-menu-right"></span>
</button>
</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>
</div>
`
})
export default class Home implements OnInit{
export default class Home implements OnInit {
public formGroup: FormGroup;
private authToken: string;
private authRole: string;
private loginInfo$: Observable<ILoginInfo>;
constructor(private fb: FormBuilder,
private _ata: LoginInfoActions,
private activatedRoute: ActivatedRoute) {
private _ngRedux: NgRedux<IAppState>,
private activatedRoute: ActivatedRoute
) {
this.authToken = '';
this.authRole = '';
this.formGroup = this.fb.group({
Username: [],
Paswd : []
Paswd: []
});
};
ngOnInit() {
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);
});
}
......@@ -53,4 +99,4 @@ export default class Home implements OnInit{
checkvalidation() {
}
}
}
......@@ -10,12 +10,9 @@ export function loginInfoReducer(state: ILoginInfo = INITIAL_STATE, action): ILo
switch (action.type) {
case LOGININFO_SAVE:
let loginInfoTokens = Array<ILoginInfoToken>();
let ind=0;
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();
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