AuthenticateOneTimeSession authenticates a session and deletes it upon successful authentication if it was marked as a one time sesssion. If it is a one time session, delete the session.
(ctx context.Context, sessionID string)
| 88 | // AuthenticateOneTimeSession authenticates a session and deletes it upon successful authentication if it was marked as |
| 89 | // a one time sesssion. If it is a one time session, delete the session. |
| 90 | func (auth *Authenticator) AuthenticateOneTimeSession(ctx context.Context, sessionID string) (User, error) { |
| 91 | session, user, err := auth.GetSession(sessionID) |
| 92 | if err != nil { |
| 93 | return nil, base.HTTPErrorf(http.StatusUnauthorized, "Session Invalid") |
| 94 | } |
| 95 | |
| 96 | err = auth.deleteOneTimeSession(ctx, session) |
| 97 | if err != nil { |
| 98 | return nil, err |
| 99 | } |
| 100 | return user, nil |
| 101 | } |
| 102 | |
| 103 | // deleteOneTimeSession deletes the session if it is marked as a one-time session. If the session can be not deleted, or |
| 104 | // was already deleted an error is returned. |