- Add session.Attach to reuse per-request sessions across middleware and ghome handlers - Make Session finalize/abort paths idempotent to avoid duplicate commit or rollback work - Move request_data parsing helper to internal/utils - Expand ParseRequestData usage across api, download, unit, live, multiunit, and subscenario handlers - Extract download package metadata into internal/handler/download/types.go - Return explicit errors from selected session lookup helpers and update callers - Make api action handlers return errors directly instead of calling ss.CheckErr in nested layers Signed-off-by: Sean Du <do4suki@gmail.com>
22 lines
517 B
Go
22 lines
517 B
Go
package session
|
|
|
|
import loginmodel "honoka-chan/internal/model/login"
|
|
|
|
func (ss *Session) GetAuthKey(token string) (bool, *loginmodel.AuthKey, error) {
|
|
authKeyData := loginmodel.AuthKey{}
|
|
has, err := ss.UserEng.Table(new(loginmodel.AuthKey)).
|
|
Where("authorize_token = ?", token).Get(&authKeyData)
|
|
if err != nil {
|
|
return false, nil, err
|
|
}
|
|
|
|
return has, &authKeyData, nil
|
|
}
|
|
|
|
func (ss *Session) SetAuthKey(authKey *loginmodel.AuthKey) {
|
|
_, err := ss.UserEng.Insert(authKey)
|
|
if ss.CheckErr(err) {
|
|
return
|
|
}
|
|
}
|