Implement more endpoints & overhaul [2/n]
Drop LevelDB and move all the things to SQLite. Implemented endpoints: /api <unit, accessoryMaterialAll> /api <unit, accessoryTab> /live/continue /live/partyList /unit/favoriteAccessory (WIP) /unit/sale Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
@@ -2,14 +2,14 @@ package login
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/middleware"
|
||||
loginmodel "honoka-chan/internal/model/login"
|
||||
"honoka-chan/internal/router"
|
||||
loginschema "honoka-chan/internal/schema/login"
|
||||
"honoka-chan/internal/session"
|
||||
"honoka-chan/pkg/db"
|
||||
"honoka-chan/pkg/encrypt"
|
||||
honokautils "honoka-chan/pkg/utils"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tidwall/gjson"
|
||||
@@ -38,18 +38,12 @@ func authKey(ctx *gin.Context) {
|
||||
serverToken := base64.StdEncoding.EncodeToString([]byte(honokautils.RandomStr(32)))
|
||||
authorizeToken := base64.StdEncoding.EncodeToString([]byte(honokautils.RandomStr(32)))
|
||||
|
||||
authJson, err := json.Marshal(map[string]any{
|
||||
"client_token": clientToken,
|
||||
"server_token": serverToken,
|
||||
ss.SetAuthKey(&loginmodel.AuthKey{
|
||||
AuthorizeToken: authorizeToken,
|
||||
ClientToken: clientToken,
|
||||
ServerToken: serverToken,
|
||||
InsertDate: time.Now().Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
err = db.Ldb.Set([]byte(authorizeToken), authJson)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
ss.Respond(loginschema.AuthKeyResp{
|
||||
ResponseData: loginschema.AuthKeyData{
|
||||
|
||||
Reference in New Issue
Block a user