[server][auth] Ensure that mail is configured for password reset and

This commit is contained in:
Abhishek Shroff
2025-07-16 00:29:03 +05:30
parent 6aea223aa3
commit fa070841a6
2 changed files with 16 additions and 4 deletions
+12 -4
View File
@@ -45,10 +45,10 @@ func SetupRoutes(r *gin.RouterGroup) {
group := r.Group("/auth")
group.GET("/config", handleConfig)
if auth.SupportsPasswordAuth() {
if passwordLoginSupported() {
group.POST("/password/login", handlePasswordAuth)
}
if auth.SupportsPasswordReset() {
if passwordResetSupported() {
group.POST("/password/request-reset", handleRequestPasswordReset)
group.POST("/password/reset", handleResetPassword)
}
@@ -61,13 +61,21 @@ func SetupRoutes(r *gin.RouterGroup) {
func handleConfig(c *gin.Context) {
response := PasswordConfigResponse{
Password: auth.SupportsPasswordAuth(),
PasswordReset: auth.SupportsPasswordReset(),
Password: passwordLoginSupported(),
PasswordReset: passwordResetSupported(),
OpenIDProviders: auth.OpenIDProviders(),
}
c.JSON(http.StatusOK, response)
}
func passwordLoginSupported() bool {
return auth.SupportsPasswordAuth()
}
func passwordResetSupported() bool {
return auth.SupportsPasswordReset() && mail.Configured()
}
func handleOAuthStart(c *gin.Context) {
provider := c.Query("provider")
clientType := auth.OpenIDClientWeb
+4
View File
@@ -36,6 +36,10 @@ func Initialize(cfg Config, l zerolog.Logger) error {
return nil
}
func Configured() bool {
return dialer != nil
}
func SendWelcomeEmail(u core.User) error {
return send(emails["welcome"], u, nil)
}