- Added support for processing environment variables in both register and form configurations, improving flexibility and configurability. - Introduced a new MessengerConfig structure for handling messenger-related settings in the register configuration. - Updated the RegisterConfig structure to include ThirdParty and InviteRequired fields, enhancing user registration options. - Refactored the registration endpoint to retrieve configuration details, ensuring a more robust registration process. - Implemented logging for missing environment variables to aid in configuration troubleshooting.
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
package user
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/yaoapp/yao/openapi/response"
|
|
"github.com/yaoapp/yao/openapi/utils"
|
|
)
|
|
|
|
// getRegisterConfig is the handler for get register configuration
|
|
func getRegisterConfig(c *gin.Context) {
|
|
// Get locale from query parameter (optional)
|
|
locale := c.Query("locale")
|
|
|
|
// Get register configuration for the specified locale (already includes third_party from signin config)
|
|
config := GetRegisterConfig(locale)
|
|
|
|
// Set session id if not exists
|
|
sid := utils.GetSessionID(c)
|
|
if sid == "" {
|
|
sid = generateSessionID()
|
|
response.SendSessionCookie(c, sid)
|
|
}
|
|
|
|
// If no configuration found, return error
|
|
if config == nil {
|
|
errorResp := &response.ErrorResponse{
|
|
Code: response.ErrInvalidRequest.Code,
|
|
ErrorDescription: "No register configuration found for the requested locale",
|
|
}
|
|
response.RespondWithError(c, response.StatusNotFound, errorResp)
|
|
return
|
|
}
|
|
|
|
// Return the register configuration
|
|
response.RespondWithSuccess(c, response.StatusOK, config)
|
|
}
|
|
|
|
// register is the handler for user registration
|
|
func register(c *gin.Context) {
|
|
// This is a placeholder - you may need to implement the actual registration logic here
|
|
}
|