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
import (
"encoding/json"
"fmt"
+ "log"
"mime/multipart"
"os"
"strings"
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{}