mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: disable enroll 2fa in demo mode
This commit is contained in:
parent
46e78f4405
commit
bcff00c47b
1 changed files with 9 additions and 2 deletions
|
@ -20,14 +20,14 @@ import (
|
|||
)
|
||||
|
||||
func GenerateTOTP(c *gin.Context) {
|
||||
user := api.CurrentUser(c)
|
||||
u := api.CurrentUser(c)
|
||||
|
||||
issuer := fmt.Sprintf("Nginx UI %s", settings.ServerSettings.Name)
|
||||
issuer = strings.TrimSpace(issuer)
|
||||
|
||||
otpOpts := totp.GenerateOpts{
|
||||
Issuer: issuer,
|
||||
AccountName: user.Name,
|
||||
AccountName: u.Name,
|
||||
Period: 30, // seconds
|
||||
Digits: otp.DigitsSix,
|
||||
Algorithm: otp.AlgorithmSHA1,
|
||||
|
@ -76,6 +76,13 @@ func EnrollTOTP(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if settings.ServerSettings.Demo {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "This feature is disabled in demo mode",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var json struct {
|
||||
Secret string `json:"secret" binding:"required"`
|
||||
Passcode string `json:"passcode" binding:"required"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue