]> git.feebdaed.xyz Git - gomehub.git/commitdiff
Modified sign in logic to override session
authorseantywork <seantywork@gmail.com>
Mon, 29 Jul 2024 00:21:00 +0000 (09:21 +0900)
committerseantywork <seantywork@gmail.com>
Mon, 29 Jul 2024 00:21:00 +0000 (09:21 +0900)
pkg/auth/auth.go
pkg/dbquery/dbquery_fs.go

index cd5d909dc49c5f5acd62eefb6e83acdda46a4595..c7f119c26a9294c35030de6361b5ca51db47c78a 100644 (file)
@@ -328,13 +328,13 @@ func UserRemove(c *gin.Context) {
 
 func Login(c *gin.Context) {
 
-       my_key, my_type, _ := WhoAmI(c)
+       my_key, my_type, my_id := WhoAmI(c)
 
        if my_key != "" && my_type != "" {
 
-               fmt.Printf("user login: already logged in\n")
+               dbquery.RemoveSessionKeyFromSession(my_key)
 
-               c.JSON(http.StatusBadRequest, com.SERVER_RE{Status: "error", Reply: "already logged in"})
+               fmt.Printf("user login: removed existing id: %s\n", my_id)
 
                return
 
index dd902d16010d5df81ad6a58db825939cb53aef3a..75fc73a163c30864b758e105a04ed5fa8c6475c0 100644 (file)
@@ -3,6 +3,7 @@ package dbquery
 import (
        "encoding/json"
        "fmt"
+       "log"
        "mime/multipart"
        "os"
        "strings"
@@ -311,12 +312,13 @@ func RemoveSessionKeyFromSession(session_key string) error {
 
 func MakeSessionForAdmin(session_key string, email string) error {
 
-       _, ss, _ := GetByIdFromSession(email)
+       s_key, ss, _ := GetByIdFromSession(email)
 
        if ss != nil {
 
-               return fmt.Errorf("valid session already exists for: %s", email)
+               _ = RemoveSessionKeyFromSession(s_key)
 
+               log.Printf("removed existing session for: %s\n", email)
        }
 
        new_ss := SessionStruct{}