mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-05-03 18:49:15 -05:00
[server][auth] Ensure that mail is configured for password reset and
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user