mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +00:00
SMQ-2958 - Fix failing reset password flow (#2970)
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
This commit is contained in:
@@ -292,7 +292,6 @@ func (req passwResetReq) validate() error {
|
||||
}
|
||||
|
||||
type resetTokenReq struct {
|
||||
Token string `json:"token"`
|
||||
Password string `json:"password"`
|
||||
ConfPass string `json:"confirm_password"`
|
||||
}
|
||||
@@ -304,9 +303,6 @@ func (req resetTokenReq) validate() error {
|
||||
if req.ConfPass == "" {
|
||||
return apiutil.ErrMissingConfPass
|
||||
}
|
||||
if req.Token == "" {
|
||||
return apiutil.ErrBearerToken
|
||||
}
|
||||
if req.Password != req.ConfPass {
|
||||
return apiutil.ErrInvalidResetPass
|
||||
}
|
||||
|
||||
@@ -623,25 +623,14 @@ func TestResetTokenReqValidate(t *testing.T) {
|
||||
{
|
||||
desc: "valid request",
|
||||
req: resetTokenReq{
|
||||
Token: valid,
|
||||
Password: secret,
|
||||
ConfPass: secret,
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "empty token",
|
||||
req: resetTokenReq{
|
||||
Token: "",
|
||||
Password: secret,
|
||||
ConfPass: secret,
|
||||
},
|
||||
err: apiutil.ErrBearerToken,
|
||||
},
|
||||
{
|
||||
desc: "empty password",
|
||||
req: resetTokenReq{
|
||||
Token: valid,
|
||||
Password: "",
|
||||
ConfPass: secret,
|
||||
},
|
||||
@@ -650,7 +639,6 @@ func TestResetTokenReqValidate(t *testing.T) {
|
||||
{
|
||||
desc: "empty confpass",
|
||||
req: resetTokenReq{
|
||||
Token: valid,
|
||||
Password: secret,
|
||||
ConfPass: "",
|
||||
},
|
||||
@@ -659,7 +647,6 @@ func TestResetTokenReqValidate(t *testing.T) {
|
||||
{
|
||||
desc: "mismatching password and confpass",
|
||||
req: resetTokenReq{
|
||||
Token: valid,
|
||||
Password: "secret",
|
||||
ConfPass: secret,
|
||||
},
|
||||
|
||||
+3
-2
@@ -275,8 +275,9 @@ func (svc service) GenerateResetToken(ctx context.Context, email, host string) e
|
||||
return errors.Wrap(svcerr.ErrViewEntity, err)
|
||||
}
|
||||
issueReq := &grpcTokenV1.IssueReq{
|
||||
UserId: user.ID,
|
||||
Type: uint32(smqauth.RecoveryKey),
|
||||
UserId: user.ID,
|
||||
UserRole: uint32(user.Role + 1),
|
||||
Type: uint32(smqauth.RecoveryKey),
|
||||
}
|
||||
token, err := svc.token.Issue(ctx, issueReq)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user