1
+ ---
2
+ title: Sttings
3
+ permalink: /setting
4
+ ---
5
+
6
+ <!DOCTYPE html>
7
+ < html lang ="id ">
8
+ < head >
9
+ < meta charset ="UTF-8 ">
10
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
11
+ < title > Fingerprint Login</ title >
12
+ < script >
13
+ document . addEventListener ( "DOMContentLoaded" , function ( ) {
14
+ const fingerprintSwitch = document . getElementById ( "fingerprintSwitch" ) ;
15
+
16
+ // Cek apakah fingerprint diaktifkan sebelumnya
17
+ function isFingerprintEnabled ( ) {
18
+ return localStorage . getItem ( "fingerprintEnabled" ) === "true" ;
19
+ }
20
+
21
+ function updateSwitchState ( ) {
22
+ fingerprintSwitch . checked = isFingerprintEnabled ( ) ;
23
+ }
24
+
25
+ function toggleFingerprint ( ) {
26
+ const isEnabled = fingerprintSwitch . checked ;
27
+ localStorage . setItem ( "fingerprintEnabled" , isEnabled ) ;
28
+ alert ( isEnabled ? "Fingerprint diaktifkan!" : "Fingerprint dimatikan!" ) ;
29
+ }
30
+
31
+ async function loginWithFingerprint ( ) {
32
+ if ( ! isFingerprintEnabled ( ) ) {
33
+ alert ( "Fingerprint belum diaktifkan." ) ;
34
+ return ;
35
+ }
36
+
37
+ if ( ! window . PublicKeyCredential ) {
38
+ alert ( "Perangkat tidak mendukung WebAuthn." ) ;
39
+ return ;
40
+ }
41
+
42
+ try {
43
+ const credential = await navigator . credentials . get ( {
44
+ publicKey : {
45
+ challenge : new Uint8Array ( 32 ) ,
46
+ allowCredentials : [ ] ,
47
+ userVerification : "required" ,
48
+ } ,
49
+ } ) ;
50
+
51
+ if ( credential ) {
52
+ alert ( "Login berhasil dengan fingerprint!" ) ;
53
+ }
54
+ } catch ( error ) {
55
+ alert ( "Autentikasi gagal: " + error . message ) ;
56
+ }
57
+ }
58
+
59
+ // Event Listener
60
+ fingerprintSwitch . addEventListener ( "change" , toggleFingerprint ) ;
61
+ document . getElementById ( "loginBtn" ) . addEventListener ( "click" , loginWithFingerprint ) ;
62
+
63
+ // Set initial switch state
64
+ updateSwitchState ( ) ;
65
+ } ) ;
66
+ </ script >
67
+ </ head >
68
+ < body >
69
+ < h2 > Pengaturan Fingerprint</ h2 >
70
+ < label >
71
+ < input type ="checkbox " id ="fingerprintSwitch ">
72
+ Aktifkan Login Fingerprint
73
+ </ label >
74
+ < br > < br >
75
+ < button id ="loginBtn "> Login dengan Fingerprint</ button >
76
+ </ body >
77
+ </ html >
0 commit comments