Refactor login cmd

This commit is contained in:
Maidul Islam
2023-02-16 15:49:14 -08:00
parent f2d7401d1d
commit 1d11f11eaf
+5 -7
View File
@@ -33,12 +33,6 @@ type params struct {
keyLength uint32 keyLength uint32
} }
func generateFromPassword(password string, salt []byte, p *params) (hash []byte, err error) {
hash = argon2.IDKey([]byte(password), salt, p.iterations, p.memory, p.parallelism, p.keyLength)
return hash, nil
}
// loginCmd represents the login command // loginCmd represents the login command
var loginCmd = &cobra.Command{ var loginCmd = &cobra.Command{
Use: "login", Use: "login",
@@ -151,7 +145,6 @@ var loginCmd = &cobra.Command{
} }
decryptedPrivateKey, err = crypto.DecryptSymmetric(decryptedProtectedKeyInHex, encryptedPrivateKey, nonProtectedTag, nonProtectedIv) decryptedPrivateKey, err = crypto.DecryptSymmetric(decryptedProtectedKeyInHex, encryptedPrivateKey, nonProtectedTag, nonProtectedIv)
if err != nil { if err != nil {
util.HandleError(err) util.HandleError(err)
} }
@@ -292,3 +285,8 @@ func shouldOverrideLoginPrompt(currentLoggedInUserEmail string) (bool, error) {
} }
return result == "Yes", err return result == "Yes", err
} }
func generateFromPassword(password string, salt []byte, p *params) (hash []byte, err error) {
hash = argon2.IDKey([]byte(password), salt, p.iterations, p.memory, p.parallelism, p.keyLength)
return hash, nil
}