@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func Checkin(c *gin.Context) {
|
||||
data := new(data.User)
|
||||
data := new(data.Checkin)
|
||||
userId, ok := c.Get("user_id")
|
||||
if !ok {
|
||||
c.JSON(401, gin.H{
|
||||
@@ -50,13 +50,29 @@ func Checkin(c *gin.Context) {
|
||||
}
|
||||
|
||||
func CheckinSubmit(c *gin.Context) {
|
||||
userId, ok := c.Get("user_id")
|
||||
if !ok {
|
||||
c.JSON(403, gin.H{
|
||||
"status": "unauthorized",
|
||||
})
|
||||
}
|
||||
|
||||
userData := new(data.User)
|
||||
userData.GetByUserId(userId.(uuid.UUID))
|
||||
if userData.PermissionLevel <= 20 {
|
||||
c.JSON(403, gin.H{
|
||||
"status": "access denied",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var req struct {
|
||||
ChekinCode string `json:"checkin_code"`
|
||||
}
|
||||
c.ShouldBindJSON(&req)
|
||||
|
||||
data := new(data.User)
|
||||
userId, err := data.VerifyCheckinCode(req.ChekinCode)
|
||||
checkinData := new(data.Checkin)
|
||||
userId, err := checkinData.VerifyCheckinCode(req.ChekinCode)
|
||||
if err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "error verify checkin code",
|
||||
@@ -64,13 +80,6 @@ func CheckinSubmit(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
data.GetByUserId(*userId)
|
||||
if data.PermissionLevel <= 20 {
|
||||
c.JSON(403, gin.H{
|
||||
"status": "access denied",
|
||||
})
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{
|
||||
"status": "success",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user