mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Fix Change Wallet Password Logic (#7324)
* fix change password logic * gaz * Merge refs/heads/master into change-password-fix * Merge refs/heads/master into change-password-fix * Merge refs/heads/master into change-password-fix * Merge refs/heads/master into change-password-fix * Merge refs/heads/master into change-password-fix * Merge refs/heads/master into change-password-fix * Merge refs/heads/master into change-password-fix * Merge refs/heads/master into change-password-fix * Merge refs/heads/master into change-password-fix * Merge refs/heads/master into change-password-fix
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
@@ -67,7 +68,10 @@ func (s *Server) Login(ctx context.Context, req *pb.AuthRequest) (*pb.AuthRespon
|
||||
WalletDir: defaultWalletPath,
|
||||
WalletPassword: req.Password,
|
||||
}); err != nil {
|
||||
return nil, status.Error(codes.Internal, "Could not initialize wallet")
|
||||
if strings.Contains(err.Error(), "invalid checksum") {
|
||||
return nil, status.Error(codes.Unauthenticated, "Incorrect password")
|
||||
}
|
||||
return nil, status.Errorf(codes.Internal, "Could not initialize wallet: %v", err)
|
||||
}
|
||||
return s.sendAuthResponse()
|
||||
}
|
||||
|
||||
@@ -165,6 +165,9 @@ func (s *Server) ChangePassword(ctx context.Context, req *pb.ChangePasswordReque
|
||||
return nil, status.Error(codes.FailedPrecondition, "Not a valid direct keymanager")
|
||||
}
|
||||
s.wallet.SetPassword(req.Password)
|
||||
if err := s.wallet.SaveHashedPassword(ctx); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not save hashed password: %v", err)
|
||||
}
|
||||
if err := km.RefreshWalletPassword(ctx); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not refresh wallet password: %v", err)
|
||||
}
|
||||
@@ -174,6 +177,9 @@ func (s *Server) ChangePassword(ctx context.Context, req *pb.ChangePasswordReque
|
||||
return nil, status.Error(codes.FailedPrecondition, "Not a valid derived keymanager")
|
||||
}
|
||||
s.wallet.SetPassword(req.Password)
|
||||
if err := s.wallet.SaveHashedPassword(ctx); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not save hashed password: %v", err)
|
||||
}
|
||||
if err := km.RefreshWalletPassword(ctx); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not refresh wallet password: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user