qor_auth_theme

package module
v0.0.0-...-7ea3fcf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 17 Imported by: 0

README

qor-auth-theme

介绍

覆写 https://github.com/qor/auth_themes 包, 修复 qor-example: Error 1054: Unknown column 'basics.provider' in 'where clause' - "invalid account" error message 报错,

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAuthorizeHandler = func(context *auth.Context) (*claims.Claims, error) {
	var (
		authInfo    auth_identity.AuthIdentity
		req         = context.Request
		tx          = context.Auth.GetDB(req)
		provider, _ = context.Provider.(*password.Provider)
	)

	_ = req.ParseForm()
	authInfo.Provider = provider.GetName()
	authInfo.UID = strings.TrimSpace(req.Form.Get("login"))

	if tx.Model(context.Auth.AuthIdentityModel).Where(authInfo).Scan(&authInfo).RecordNotFound() {
		return nil, errors.New("请输入正确账号")
	}

	if provider.Config.Confirmable && authInfo.ConfirmedAt == nil {
		currentUser, _ := context.Auth.UserStorer.Get(authInfo.ToClaims(), context)
		_ = provider.Config.ConfirmMailer(authInfo.UID, context, authInfo.ToClaims(), currentUser)

		return nil, errors.New("请确认你的账号,再继续")
	}

	if err := provider.Encryptor.Compare(authInfo.EncryptedPassword, strings.TrimSpace(req.Form.Get("password"))); err == nil {
		return authInfo.ToClaims(), err
	}

	return nil, errors.New("请输入正确密码")
}
View Source
var ErrPasswordConfirmationNotMatch = errors.New("两次密码输入不一致")

ErrPasswordConfirmationNotMatch password confirmation not match error

Functions

func New

func New(config *auth.Config) *auth.Auth

New initialize clean theme

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL