mirror of https://github.com/synctv-org/synctv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
583 B
Go
30 lines
583 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/synctv-org/synctv/internal/op"
|
|
"github.com/synctv-org/synctv/server/model"
|
|
)
|
|
|
|
func Me(ctx *gin.Context) {
|
|
user := ctx.MustGet("user").(*op.User)
|
|
|
|
ctx.JSON(http.StatusOK, model.NewApiDataResp(gin.H{
|
|
"username": user.Username,
|
|
}))
|
|
}
|
|
|
|
func LogoutUser(ctx *gin.Context) {
|
|
user := ctx.MustGet("user").(*op.User)
|
|
|
|
err := op.DeleteUserByID(user.ID)
|
|
if err != nil {
|
|
ctx.AbortWithStatusJSON(http.StatusInternalServerError, model.NewApiErrorResp(err))
|
|
return
|
|
}
|
|
|
|
ctx.Status(http.StatusNoContent)
|
|
}
|