Skip to content

Commit bcff00c

Browse files
committed
feat: disable enroll 2fa in demo mode
1 parent 46e78f4 commit bcff00c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

api/user/otp.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ import (
2020
)
2121

2222
func GenerateTOTP(c *gin.Context) {
23-
user := api.CurrentUser(c)
23+
u := api.CurrentUser(c)
2424

2525
issuer := fmt.Sprintf("Nginx UI %s", settings.ServerSettings.Name)
2626
issuer = strings.TrimSpace(issuer)
2727

2828
otpOpts := totp.GenerateOpts{
2929
Issuer: issuer,
30-
AccountName: user.Name,
30+
AccountName: u.Name,
3131
Period: 30, // seconds
3232
Digits: otp.DigitsSix,
3333
Algorithm: otp.AlgorithmSHA1,
@@ -76,6 +76,13 @@ func EnrollTOTP(c *gin.Context) {
7676
return
7777
}
7878

79+
if settings.ServerSettings.Demo {
80+
c.JSON(http.StatusBadRequest, gin.H{
81+
"message": "This feature is disabled in demo mode",
82+
})
83+
return
84+
}
85+
7986
var json struct {
8087
Secret string `json:"secret" binding:"required"`
8188
Passcode string `json:"passcode" binding:"required"`

0 commit comments

Comments
 (0)