1
0
mirror of https://github.com/dkmstr/openuds-gui.git synced 2024-10-26 08:55:23 +03:00

fixed login & proxy. now working and compatible with previous UDS templates :)

This commit is contained in:
Adolfo Gómez García 2018-08-22 05:42:48 +02:00
parent 976547004b
commit f060dd08a2
3 changed files with 34 additions and 9 deletions

View File

@ -29,7 +29,17 @@
"changeOrigin": true,
"logLevel": "info"
},
"/log.*": {
"/login/": {
"target": {
"host": "172.27.0.1",
"protocol": "http:",
"port": 8000
},
"secure": false,
"changeOrigin": true,
"logLevel": "info"
},
"/logout": {
"target": {
"host": "172.27.0.1",
"protocol": "http:",

View File

@ -7,27 +7,29 @@
<div class="card fat">
<div class="card-body">
<h4 class="card-title text-center">UDS Enterprise</h4>
<form>
<form id="loginform" method="post">
<input name="" id="token" value="" type="hidden">
<input name="logouturl" id="id_logouturl" value="" type="hidden">
<div class="form-group">
<label for="user">
<uds-translate>Username</uds-translate>
</label>
<input id="user" type="user" class="form-control" name="user" value="" required autofocus>
<input id="id_user" type="user" class="form-control" name="user" value="" required autofocus>
</div>
<div class="form-group">
<label for="password">
<uds-translate>Password</uds-translate>
</label>
<input id="password" type="password" class="form-control" name="password" data-eye>
<input id="id_password" type="password" class="form-control" name="password" data-eye>
</div>
<div class="form-group" *ngIf="auths.length > 1">
<label>
<uds-translate>Authenticator</uds-translate>
</label>
<select class="custom-select" (change)="changeAuth($event.target.value)">
<select name="authenticator" class="custom-select" (change)="changeAuth($event.target.value)">
<option *ngFor="let a of auths" value="{{ a.id }}">{{ a.name }}</option>
</select>
</div>
@ -46,3 +48,4 @@
</div>
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { UdsApiService, Authenticator } from '../uds-api.service';
import { Authenticator, UdsApiService } from '../uds-api.service';
@Component({
selector: 'uds-login',
@ -16,11 +16,23 @@ export class LoginComponent implements OnInit {
}
ngOnInit() {
// We want to keep compatibility right now with previous UDS templates, so we
// adapt form to post the correct values the correct way
const form = <HTMLFormElement>document.getElementById('loginform');
if (form.action.slice(-1) !== '/') {
form.action += '/';
}
const input = (<HTMLInputElement>document.getElementById('token'));
input.name = this.api.config.csrf_field;
input.value = this.api.config.csrf;
}
changeAuth(auth) {
function doChangeAuth(result: string) {
alert(result);
// Ejecuted when custom auth selected
function doCustomAuth(data: string) {
// tslint:disable-next-line:no-eval
eval(data);
}
for (const l of this.auths) {
@ -28,7 +40,7 @@ export class LoginComponent implements OnInit {
if (l.is_custom) { // If is custom, we should get the code from server to authentication
this.api.getAuthCustomHtml(l.id)
.subscribe(result => doChangeAuth(result));
.subscribe(result => doCustomAuth(result));
}
}
}