You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
475 B
23 lines
475 B
package auth
|
|
|
|
import (
|
|
"task-track-backend/model"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (h *AuthHandler) Me(c *gin.Context) {
|
|
userID, exists := c.Get("user_id")
|
|
if !exists {
|
|
c.JSON(401, gin.H{"code": 401, "message": "Unauthorized"})
|
|
return
|
|
}
|
|
|
|
var user model.User
|
|
if err := h.db.First(&user, userID).Error; err != nil {
|
|
c.JSON(404, gin.H{"code": 404, "message": "User not found"})
|
|
return
|
|
}
|
|
|
|
c.JSON(200, gin.H{"code": 200, "message": "Success", "data": user})
|
|
}
|
|
|