-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 2FA TOTP generation for delivery persons
Implemented TOTP generation for delivery persons and updated related models and functions to store authentication keys and URLs. Adjusted handler and service logic to accommodate these changes while ensuring data consistency and error handling.
- Loading branch information
1 parent
1792b5c
commit ffe7840
Showing
7 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package delivery | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"github.com/pquerna/otp/totp" | ||
) | ||
|
||
func (deliverSrv *DeliveryService) GenerateTOTP(_ context.Context, phone string) (string, string, error) { | ||
key, err := totp.Generate(totp.GenerateOpts{ | ||
Issuer: "Food Delivery", | ||
AccountName: phone, | ||
}) | ||
if err != nil { | ||
return "", "", errors.New("error generating key") | ||
} | ||
return key.Secret(), key.URL(), nil | ||
} |