2024-01-14 15:53:37 +00:00
|
|
|
package redisotp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
2024-01-15 10:33:24 +00:00
|
|
|
|
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
2024-01-14 15:53:37 +00:00
|
|
|
)
|
|
|
|
|
2024-01-15 10:33:24 +00:00
|
|
|
func (d DB) SaveCodeWithPhoneNumber(ctx context.Context, phoneNumber, code string, expireTime time.Duration) error {
|
2024-01-14 15:53:37 +00:00
|
|
|
const op = "redisotp.SaveCodeWithPhoneNumber"
|
2024-01-15 10:33:24 +00:00
|
|
|
|
2024-01-14 15:53:37 +00:00
|
|
|
err := d.adapter.Client().Set(ctx, phoneNumber, code, expireTime).Err()
|
|
|
|
if err != nil {
|
|
|
|
return richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|