Exemplo n.º 1
0
func oauth2SignInHandler(handler oauth2.OAuth2TokenHandler, client *oauth2.Client, scopes []string) app.Handler {
	if handler != nil && client != nil {
		h := oauth2.Handler(handler, client, scopes)
		return app.Anonymous(h)
	}
	return nil
}
Exemplo n.º 2
0
	FacebookChannelHandlerName = "users-facebook-channel"
	ImageHandlerName           = "users-image-handler"

	SignInTemplateName      = "sign-in.html"
	SignInModalTemplateName = "sign-in-modal.html"
	SignUpTemplateName      = "sign-up.html"
	ForgotTemplateName      = "forgot.html"
	ResetTemplateName       = "reset.html"
)

var (
	Salt                = []byte("gnd.la/apps/users")
	PasswordResetExpiry = 24 * time.Hour
	SignInHandlerName   = app.SignInHandlerName

	SignInHandler           = app.Anonymous(signInHandler)
	SignUpHandler           = app.Anonymous(signUpHandler)
	SignOutHandler          = app.SignOutHandler
	ForgotHandler           = app.Anonymous(forgotHandler)
	JSSignInHandler         = app.Anonymous(jsSignInHandler)
	JSSignInFacebookHandler = app.Anonymous(jsSignInFacebookHandler)
	JSSignInGoogleHandler   = app.Anonymous(jsSignInGoogleHandler)
	JSSignUpHandler         = app.Anonymous(jsSignUpHandler)
)

func signInHandler(ctx *app.Context) {
	modal := ctx.FormValue("modal") != ""
	d := data(ctx)
	if !modal && !d.allowDirectSignIn() && d.hasEnabledSocialSignin() {
		// Redirect to the only available social sign-in
		ctx.MustRedirectReverse(false, d.enabledSocialAccountTypes()[0].HandlerName)