-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
202 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import router from "../router"; | ||
import { securityConfig } from "./config"; | ||
import sha1 from "./util/sha1"; | ||
|
||
let isLocked = true; | ||
|
||
export function getLockedStatus(){ | ||
if (securityConfig.password === undefined || !securityConfig.usePassword) return false; | ||
return isLocked; | ||
} | ||
|
||
export function unlock(plaintextPwd: string) { | ||
const password = new TextDecoder().decode(sha1(new TextEncoder().encode(plaintextPwd))); | ||
|
||
if(securityConfig.password === password) { | ||
isLocked = false; | ||
router.replace("/"); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
export function disableApplock(plaintextPwd: string) { | ||
const password = new TextDecoder().decode(sha1(new TextEncoder().encode(plaintextPwd))); | ||
|
||
if (securityConfig.password === password) { | ||
isLocked = false; | ||
securityConfig.usePassword = false; | ||
securityConfig.password = undefined; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
export function enableApplock(plaintextPwd: string) { | ||
if(isLocked) return false; | ||
|
||
const password = new TextDecoder().decode(sha1(new TextEncoder().encode(plaintextPwd))); | ||
securityConfig.password = password; | ||
securityConfig.usePassword = true; | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<script setup lang="ts"> | ||
import { IonPage, IonContent, IonLabel, IonInput } from "@ionic/vue"; | ||
import { unlock } from "../lib/applock"; | ||
function checkAndTryUnlocking(e){ | ||
console.log(unlock(e.detail.value)); | ||
} | ||
</script> | ||
|
||
<template> | ||
<IonPage> | ||
<IonContent> | ||
|
||
<div> | ||
<IonLabel> | ||
<h1>{{ $t("lock:title") }}</h1> | ||
</IonLabel> | ||
<IonInput | ||
fill="outline" | ||
type="password" | ||
labelPlacement="floating" | ||
:label="$t('lock:hint')" | ||
@ionInput="checkAndTryUnlocking" | ||
></IonInput> | ||
</div> | ||
|
||
</IonContent> | ||
</IonPage> | ||
</template> | ||
|
||
<style scoped> | ||
div { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 16px; | ||
width: 100%; | ||
height: 100%; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
padding: 24px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"title": "The app is locked", | ||
"hint": "Please input your app password" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters