// Authenticates the current user.
Authenticates the current user.
// Authenticates the current user .
func (a *SessionAuthenticator) Authenticate(r *http.Request, w http.ResponseWriter) (auth.Identity, error) {
	ctx := r.Context()
	authKey := a.sessionManager.GetString(ctx, "auth_key")
	if authKey == "" {
		return nil, errors.New("no logged user")
	}
	var user models.User
	if err := models.FindUserByAuthKey(ctx, a.db, &user, authKey); err != nil {
		return nil, err
	}
	return &user, nil
}
func ( a * SessionAuthenticator ) Authenticate ( r * http . Request , w http . ResponseWriter ) ( auth . Identity , error ) { ctx := r . Context ( ) authKey := a . sessionManager . GetString ( ctx , " " ) if authKey == " " { return nil , errors . New ( " " ) } var user models . User if err := models . FindUserByAuthKey ( ctx , a . db , & user , authKey ) ; err != nil { return nil , err } return & user , nil }
Authenticates the current user.
Authenticates the current user .