auto logout
This commit is contained in:
@@ -42,16 +42,21 @@ func ParseJSON(r *http.Request, v any) error {
|
||||
}
|
||||
|
||||
func GetTokenFromRequest(r *http.Request) string {
|
||||
tokenAuth := r.Header.Get("Authorization")
|
||||
if strings.HasPrefix(tokenAuth, "Bearer ") {
|
||||
return strings.TrimPrefix(tokenAuth, "Bearer ")
|
||||
}
|
||||
// fmt.Printf("Request: %v\n", r.)
|
||||
var tokenAuth string
|
||||
tokenAuth = r.Header.Get("Authorization")
|
||||
// fmt.Printf("Token Auth: %v\n", tokenAuth)
|
||||
|
||||
tokenQuery := r.URL.Query().Get("token")
|
||||
// fmt.Printf("Token Query: %v\n", tokenQuery)
|
||||
if tokenQuery != "" {
|
||||
return tokenQuery
|
||||
tokenAuth = tokenQuery
|
||||
}
|
||||
return ""
|
||||
tokenAuth = strings.TrimSpace(tokenAuth)
|
||||
tokenAuth = strings.ReplaceAll(tokenAuth, "Bearer", "")
|
||||
tokenAuth = strings.ReplaceAll(tokenAuth, "\"", "")
|
||||
tokenAuth = strings.TrimSpace(tokenAuth)
|
||||
return tokenAuth
|
||||
}
|
||||
|
||||
func MatchStruct(src interface{}, dst interface{}) error {
|
||||
|
||||
Reference in New Issue
Block a user