Skip to content
Snippets Groups Projects
Commit 82cb8e81 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Convert GetOrInitPassword to return a promise and throw the exception directly

parent 0c7288d1
No related branches found
No related tags found
1 merge request!109Project/haven beta
...@@ -93,17 +93,20 @@ const ( ...@@ -93,17 +93,20 @@ const (
// Parameters: // Parameters:
// - args[0] - The user supplied password (string). // - args[0] - The user supplied password (string).
// //
// Returns: // Returns a promise:
// - Internal password (Uint8Array). // - Internal password (Uint8Array).
// - Throws TypeError on failure. // - Throws TypeError on failure.
func GetOrInitPassword(_ js.Value, args []js.Value) any { func GetOrInitPassword(_ js.Value, args []js.Value) any {
internalPassword, err := getOrInit(args[0].String()) promiseFn := func(resolve, reject func(args ...any) js.Value) {
if err != nil { internalPassword, err := getOrInit(args[0].String())
exception.ThrowTrace(err) if err != nil {
return nil reject(exception.NewTrace(err))
} else {
resolve(utils.CopyBytesToJS(internalPassword))
}
} }
return utils.CopyBytesToJS(internalPassword) return utils.CreatePromise(promiseFn)
} }
// ChangeExternalPassword allows a user to change their external password. // ChangeExternalPassword allows a user to change their external password.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment