Skip to content

Commit

Permalink
feat(core): check timezone (#1925)
Browse files Browse the repository at this point in the history
  • Loading branch information
liquid36 authored Sep 29, 2020
1 parent 2ab630b commit f178ae0
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/app/apps/auth/components/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Router } from '@angular/router';
import { Plex } from '@andes/plex';
import { Auth } from '@andes/auth';
import { WebSocketService } from '../../../../services/websocket.service';
import { HotjarService } from '../../../../shared/services/hotJar.service';

@Component({
templateUrl: 'login.html',
Expand All @@ -14,7 +13,6 @@ export class LoginComponent implements OnInit {
public usuario: number;
public password: string;
public loading = false;
public regionesValidas = ['America/Buenos_Aires', 'America/Catamarca', 'America/Cordoba', 'America/Jujuy', 'America/Argentina/La_Rioja', 'America/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Salta', 'America/Argentina/San_Juan', 'America/Argentina/San_Luis', 'America/Argentina/Tucuman', 'America/Argentina/Ushuaia'];

constructor(
private plex: Plex,
Expand All @@ -28,22 +26,16 @@ export class LoginComponent implements OnInit {
this.ws.close();
}

husoHorarioCorrecto() {
let timeZone;
let result = false;
if (typeof Intl === 'object' && typeof Intl.DateTimeFormat === 'function') {
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (this.regionesValidas.indexOf(timeZone) === -1) {
this.plex.info('danger', 'Su computadora está configurada en una región no válida. Por favor, verifique y vuelva a intentar.');
this.loading = false;
} else {
result = true;
}
}
return result;
checkTimezone() {
const timeZone = new Date().getTimezoneOffset();
return timeZone === 180;
}

login(event) {
if (!this.checkTimezone()) {
this.plex.info('danger', 'La hora de la computadora es incorrecta. Chequea el huso horario.');
return;
}
if (event.formValid) {
this.loading = true;
this.auth.login(this.usuario.toString(), this.password)
Expand Down

0 comments on commit f178ae0

Please sign in to comment.