Skip to content

Commit

Permalink
Add lock action to account
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreb committed Jul 4, 2024
1 parent 4a16c48 commit fc19566
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
12 changes: 12 additions & 0 deletions app/src/app/identity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ export class IdentityService {
await agent.vault.changePassword({ oldPassword, newPassword });
}

async lock() {
// TODO: Validate if we need to do more when locking the account.
console.log('Locking account...');

const agent = this.web5.agent as Web5IdentityAgent;
await agent.vault.lock();

console.log('Vault locked');

this.locked.set(true);
}

async unlock(password: string) {
console.log('Connecting to Web5...');

Expand Down
2 changes: 1 addition & 1 deletion app/src/app/layout/layout.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<span>Accounts</span>
</button>

<button mat-menu-item>
<button mat-menu-item (click)="lock()">
<mat-icon>lock</mat-icon>
<span>Lock account</span>
</button>
Expand Down
7 changes: 7 additions & 0 deletions app/src/app/layout/layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ThemeToggleComponent } from '../theme-toggle/theme-toggle.component';
import { LayoutService } from '../layout.service';
import { MatMenuModule } from '@angular/material/menu';
import { StorageService } from '../storage.service';
import { IdentityService } from '../identity.service';

@Component({
selector: 'app-layout',
Expand All @@ -38,6 +39,8 @@ export class LayoutComponent {

private storage = inject(StorageService);

private identity = inject(IdentityService);

rootRoutes = routes.filter(r=>r.path).filter(r=>r.data && r.data['hide'] != true);

async wipe() {
Expand All @@ -60,6 +63,10 @@ export class LayoutComponent {
window.location.reload();
}

lock() {
this.identity.lock();
}

isHandset$: Observable<boolean> = this.breakpointObserver.observe('(max-width: 700px)')
.pipe(
map(result => result.matches),
Expand Down

0 comments on commit fc19566

Please sign in to comment.