Skip to content

Commit

Permalink
Add TaskCheck func
Browse files Browse the repository at this point in the history
  • Loading branch information
gentee committed Feb 14, 2022
1 parent 7c40623 commit ef5ca82
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pro.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"eonza/users"
"fmt"
"net/http"
"time"

pro "github.com/gentee/eonza-pro"
"github.com/labstack/echo/v4"
Expand Down Expand Up @@ -123,10 +124,21 @@ func GetTrialMode() int {
return storage.Trial.Mode
}

func TaskCheck(taskID uint32, userID uint32) error {
if v, ok := tasks[taskID]; ok && v.UserID == userID {
if v.Status == TaskActive || v.Status == TaskWaiting ||
(v.Status == TaskFinished && time.Now().Unix() <= v.FinishTime+1) {
return nil
}
}
return fmt.Errorf(`access denied task %d / user %d`, taskID, userID)
}

func ProInit(psw []byte, counter uint32) {
pro.CallbackPassCounter = StoragePassCounter
pro.CallbackTitle = GetTitle
pro.CallbackTrial = GetTrialMode
pro.CallbackTaskCheck = TaskCheck
pro.LoadPro(psw, counter, cfg.path, cfg.Users.Dir)
}

Expand Down

0 comments on commit ef5ca82

Please sign in to comment.