mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 05:45:50 +00:00
Merge branch 'developer' of https://bitbucket.org/equilibriumito/gabinete-digital into developer
This commit is contained in:
@@ -1,7 +1,31 @@
|
|||||||
|
export class UserForm {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
domainName: string;
|
||||||
|
BasicAuthKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export class User {
|
export class User {
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
domainName: string;
|
domainName: string;
|
||||||
BasicAuthKey: string;
|
BasicAuthKey: string;
|
||||||
UserId?: number;
|
UserId?: number;
|
||||||
|
Authorization: string;
|
||||||
|
Email: string
|
||||||
|
FullName: string
|
||||||
|
OwnerCalendars: {
|
||||||
|
CalendarId: string
|
||||||
|
CalendarName: "Oficial" | "Pessoal"
|
||||||
|
Id: 1
|
||||||
|
}[]
|
||||||
|
RoleDescription: string
|
||||||
|
RoleID: number
|
||||||
|
SharedCalendars: {
|
||||||
|
CalendarId: string
|
||||||
|
CalendarName: "Oficial" | "Pessoal"
|
||||||
|
Id: 1
|
||||||
|
}[]
|
||||||
|
UserName: string
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { AuthService } from 'src/app/services/auth.service';
|
import { AuthService } from 'src/app/services/auth.service';
|
||||||
import { User } from 'src/app/models/user.model';
|
import { User, UserForm } from 'src/app/models/user.model';
|
||||||
import { ToastService } from 'src/app/services/toast.service';
|
import { ToastService } from 'src/app/services/toast.service';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { AlertController } from '@ionic/angular';
|
import { AlertController } from '@ionic/angular';
|
||||||
@@ -29,7 +29,7 @@ export class LoginPage implements OnInit {
|
|||||||
logstatus: boolean;
|
logstatus: boolean;
|
||||||
username: string = environment.defaultuser;
|
username: string = environment.defaultuser;
|
||||||
password: string = environment.defaultuserpwd;
|
password: string = environment.defaultuserpwd;
|
||||||
userattempt: User;
|
userattempt: UserForm;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { StorageService } from './storage.service';
|
import { StorageService } from './storage.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
import { User } from '../models/user.model';
|
import { User, UserForm } from '../models/user.model';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { HttpService } from './http.service';
|
import { HttpService } from './http.service';
|
||||||
import { BehaviorSubject, Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
@@ -15,25 +15,26 @@ export class AuthService {
|
|||||||
userData$ = new BehaviorSubject<any>('');
|
userData$ = new BehaviorSubject<any>('');
|
||||||
userId$ = new BehaviorSubject<any>('');
|
userId$ = new BehaviorSubject<any>('');
|
||||||
headers: HttpHeaders;
|
headers: HttpHeaders;
|
||||||
|
public ValidatedUser:User;
|
||||||
opts:any;
|
opts:any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
private httpService: HttpService,
|
private httpService: HttpService,
|
||||||
private storageService:StorageService,
|
private storageService:StorageService,
|
||||||
private router:Router
|
private router:Router
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.headers = new HttpHeaders();
|
this.headers = new HttpHeaders();
|
||||||
|
|
||||||
//if(!environment.production){
|
|
||||||
if (localStorage.getItem("user") != null) {
|
if (localStorage.getItem("user") != null) {
|
||||||
this.ValidatedUser = JSON.parse(localStorage.getItem('user'));
|
this.ValidatedUser = JSON.parse(localStorage.getItem('user'));
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public ValidatedUser:User;
|
|
||||||
|
|
||||||
async login(user: User): Promise<boolean> {
|
|
||||||
|
async login(user: UserForm): Promise<boolean> {
|
||||||
user.BasicAuthKey = 'Basic ' + btoa(user.username + '@' + user.domainName + ':' + user.password); //conversão em base64 das credenciais inseridas
|
user.BasicAuthKey = 'Basic ' + btoa(user.username + '@' + user.domainName + ':' + user.password); //conversão em base64 das credenciais inseridas
|
||||||
|
|
||||||
|
|
||||||
@@ -48,17 +49,14 @@ export class AuthService {
|
|||||||
let response: any;
|
let response: any;
|
||||||
|
|
||||||
result = await this.http.get<boolean>(service, options).toPromise();
|
result = await this.http.get<boolean>(service, options).toPromise();
|
||||||
response = await this.http.post<any>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise();
|
response = await this.http.post<User>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise();
|
||||||
|
|
||||||
if (result)
|
console.log(response)
|
||||||
{
|
|
||||||
this.ValidatedUser = user;
|
|
||||||
console.log(user);
|
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
this.ValidatedUser = response;
|
||||||
|
|
||||||
//if(!environment.production){
|
localStorage.setItem('user', JSON.stringify(response));
|
||||||
localStorage.setItem('user', JSON.stringify(Object.assign(user, response)));
|
|
||||||
//}
|
|
||||||
|
|
||||||
this.storageService.store(AuthConnstants.USER, response);
|
this.storageService.store(AuthConnstants.USER, response);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user