add method logout
rename auth method to login
This commit is contained in:
1 parent
7ab0e77a97
commit
8c0513d394
4 files changed
+27
-4
No files matched your search
@@ -8,12 +8,18 @@ import (
|
||||
)
|
||||
|
||||
const DELETE_TOKENS = "DELETE FROM " + utils.DB_SCHEME + ".tokens WHERE user_id=?"
|
||||
const DELETE_TOKEN = "DELETE FROM " + utils.DB_SCHEME + ".tokens WHERE token=?"
|
||||
|
||||
func InvalidateOldTokens(userId int64) (int, error) {
|
||||
result, err := database.GetDBManager().Db.Exec(DELETE_TOKENS, userId)
|
||||
return result.RowsAffected(), err
|
||||
}
|
||||
|
||||
func InvalidateOldToken(token string) (int, error) {
|
||||
result, err := database.GetDBManager().Db.Exec(DELETE_TOKEN, token)
|
||||
return result.RowsAffected(), err
|
||||
}
|
||||
|
||||
func CreateNewToken(userId int64, tokenString string, expiredTime *time.Time) (*libStr.AdminToken, error) {
|
||||
token := libStr.AdminToken{UserId: userId, Token: tokenString}
|
||||
if expiredTime != nil {
|
||||
|
||||
Reference in new issue
Block a user