1
0
mirror of https://github.com/bitwarden/web synced 2025-12-06 00:03:28 +00:00
Files
web/src/app/settings/profile.component.ts
Oscar Hinton b12d0387f6 Add jslib as a "real" dependency (#951)
* Add jslib as a dependency

* Cleanup tsconfig, webpack, add jslib-angular to package.json

* Update all import paths

* Add back @types/node.

* Lint

* Remove dummy module

* Remove merge conflict

* Group imports

* Bump jslib
2021-06-07 20:13:58 +02:00

50 lines
1.7 KiB
TypeScript

import {
Component,
OnInit,
} from '@angular/core';
import { ToasterService } from 'angular2-toaster';
import { ApiService } from 'jslib-common/abstractions/api.service';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { UpdateProfileRequest } from 'jslib-common/models/request/updateProfileRequest';
import { ProfileResponse } from 'jslib-common/models/response/profileResponse';
@Component({
selector: 'app-profile',
templateUrl: 'profile.component.html',
})
export class ProfileComponent implements OnInit {
loading = true;
profile: ProfileResponse;
fingerprint: string;
formPromise: Promise<any>;
constructor(private apiService: ApiService, private i18nService: I18nService,
private toasterService: ToasterService, private userService: UserService,
private cryptoService: CryptoService) { }
async ngOnInit() {
this.profile = await this.apiService.getProfile();
this.loading = false;
const fingerprint = await this.cryptoService.getFingerprint(await this.userService.getUserId());
if (fingerprint != null) {
this.fingerprint = fingerprint.join('-');
}
}
async submit() {
try {
const request = new UpdateProfileRequest(this.profile.name, this.profile.masterPasswordHint);
this.formPromise = this.apiService.putProfile(request);
await this.formPromise;
this.toasterService.popAsync('success', null, this.i18nService.t('accountUpdated'));
} catch { }
}
}