2018-04-27 23:38:46 -04:00
|
|
|
// Copyright 2018 Frédéric Guillot. All rights reserved.
|
2017-11-28 00:30:04 -05:00
|
|
|
// Use of this source code is governed by the Apache 2.0
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package middleware
|
|
|
|
|
2017-12-16 21:07:53 -05:00
|
|
|
// ContextKey represents a context key.
|
|
|
|
type ContextKey struct {
|
2017-11-28 00:30:04 -05:00
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2017-12-16 21:07:53 -05:00
|
|
|
func (c ContextKey) String() string {
|
|
|
|
return c.name
|
|
|
|
}
|
|
|
|
|
2017-11-28 00:30:04 -05:00
|
|
|
var (
|
|
|
|
// UserIDContextKey is the context key used to store the user ID.
|
2017-12-16 21:07:53 -05:00
|
|
|
UserIDContextKey = &ContextKey{"UserID"}
|
2017-11-28 00:30:04 -05:00
|
|
|
|
|
|
|
// UserTimezoneContextKey is the context key used to store the user timezone.
|
2017-12-16 21:07:53 -05:00
|
|
|
UserTimezoneContextKey = &ContextKey{"UserTimezone"}
|
2017-11-28 00:30:04 -05:00
|
|
|
|
|
|
|
// IsAdminUserContextKey is the context key used to store the user role.
|
2017-12-16 21:07:53 -05:00
|
|
|
IsAdminUserContextKey = &ContextKey{"IsAdminUser"}
|
2017-11-28 00:30:04 -05:00
|
|
|
|
|
|
|
// IsAuthenticatedContextKey is the context key used to store the authentication flag.
|
2017-12-16 21:07:53 -05:00
|
|
|
IsAuthenticatedContextKey = &ContextKey{"IsAuthenticated"}
|
|
|
|
|
|
|
|
// UserSessionTokenContextKey is the context key used to store the user session ID.
|
|
|
|
UserSessionTokenContextKey = &ContextKey{"UserSessionToken"}
|
|
|
|
|
2018-01-19 00:53:31 -05:00
|
|
|
// UserLanguageContextKey is the context key to store user language.
|
|
|
|
UserLanguageContextKey = &ContextKey{"UserLanguageContextKey"}
|
|
|
|
|
2017-12-16 21:07:53 -05:00
|
|
|
// SessionIDContextKey is the context key used to store the session ID.
|
|
|
|
SessionIDContextKey = &ContextKey{"SessionID"}
|
|
|
|
|
|
|
|
// CSRFContextKey is the context key used to store CSRF token.
|
|
|
|
CSRFContextKey = &ContextKey{"CSRF"}
|
|
|
|
|
|
|
|
// OAuth2StateContextKey is the context key used to store OAuth2 state.
|
|
|
|
OAuth2StateContextKey = &ContextKey{"OAuth2State"}
|
|
|
|
|
|
|
|
// FlashMessageContextKey is the context key used to store a flash message.
|
|
|
|
FlashMessageContextKey = &ContextKey{"FlashMessage"}
|
2017-11-28 00:30:04 -05:00
|
|
|
|
2017-12-16 21:07:53 -05:00
|
|
|
// FlashErrorMessageContextKey is the context key used to store a flash error message.
|
|
|
|
FlashErrorMessageContextKey = &ContextKey{"FlashErrorMessage"}
|
2018-05-20 18:29:14 -04:00
|
|
|
|
|
|
|
// PocketRequestTokenContextKey is the context key for Pocket Request Token.
|
|
|
|
PocketRequestTokenContextKey = &ContextKey{"PocketRequestToken"}
|
2017-11-28 00:30:04 -05:00
|
|
|
)
|