mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-18 17:46:37 +08:00
feat: Implement API endpoints for user management and information retrieval
- Added new API endpoints for user information retrieval, registration, login, logout, self-management, administration, options management, channel management, token management, redemption management, log management, and group retrieval - Improved authentication flow with GitHub, WeChat, and email - Added a function `GetSelfByToken` for getting user information using an OpenAI API token
This commit is contained in:
parent
3ae5063626
commit
1c46d030ab
@ -312,6 +312,16 @@ func GetAffCode(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetSelfByToken get user by openai api token
|
||||
func GetSelfByToken(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"uid": c.GetInt("id"),
|
||||
"token_id": c.GetInt("token_id"),
|
||||
"username": c.GetString("username"),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func GetSelf(c *gin.Context) {
|
||||
id := c.GetInt("id")
|
||||
user, err := model.GetUserById(id, false)
|
||||
|
@ -19,6 +19,7 @@ func SetApiRouter(router *gin.Engine) {
|
||||
apiRouter.GET("/home_page_content", controller.GetHomePageContent)
|
||||
apiRouter.GET("/verification", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.SendEmailVerification)
|
||||
apiRouter.GET("/reset_password", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.SendPasswordResetEmail)
|
||||
apiRouter.GET("/user/get-by-token", middleware.TokenAuth(), controller.GetSelfByToken)
|
||||
apiRouter.POST("/user/reset", middleware.CriticalRateLimit(), controller.ResetPassword)
|
||||
apiRouter.GET("/oauth/github", middleware.CriticalRateLimit(), controller.GitHubOAuth)
|
||||
apiRouter.GET("/oauth/state", middleware.CriticalRateLimit(), controller.GenerateOAuthCode)
|
||||
|
Loading…
Reference in New Issue
Block a user