auth

package
v0.0.0-...-a64d9b0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanRegistered

func CanRegistered(userName string, email string) (bool, bool, error)

CanRegistered checks if the username or e-mail is available.

func CreateUserActiveCode

func CreateUserActiveCode(user *models.User, startInf interface{}) string

create a time limit code for user active

func CreateUserResetPwdCode

func CreateUserResetPwdCode(user *models.User, startInf interface{}) string

create a time limit code for user reset password

func DeleteRememberCookie

func DeleteRememberCookie(ctx *context.Context)

func GetLoginRedirect

func GetLoginRedirect(ctx *context.Context) string

get login redirect url from cookie

func GetUserFromSession

func GetUserFromSession(user *models.User, sess session.Store) bool

get user if key exist in session

func GetUserIdFromSession

func GetUserIdFromSession(sess session.Store) int

func HasUser

func HasUser(user *models.User, username string) bool

check if exist user by username or email

func LoginUser

func LoginUser(user *models.User, ctx *context.Context, remember bool)

login user

func LoginUserFromRememberCookie

func LoginUserFromRememberCookie(user *models.User, ctx *context.Context) (success bool)

func LogoutUser

func LogoutUser(ctx *context.Context)

logout user

func RegisterUser

func RegisterUser(user *models.User, username, email, password string) error

register create user

func SaveNewPassword

func SaveNewPassword(user *models.User, password string) error

set a new password to user

func SendActiveMail

func SendActiveMail(locale i18n.Locale, user *models.User)

Send email verify active email.

func SendRegisterMail

func SendRegisterMail(locale i18n.Locale, user *models.User)

Send user register mail with active code

func SendResetPwdMail

func SendResetPwdMail(locale i18n.Locale, user *models.User)

Send user reset password mail with verify code

func UserFollow

func UserFollow(user *models.User, theUser *models.User)

func UserUnFollow

func UserUnFollow(user *models.User, theUser *models.User)

func VerifyPassword

func VerifyPassword(rawPwd, encodedPwd string) bool

compare raw password and encoded password

func VerifyUser

func VerifyUser(user *models.User, username, password string) (success bool)

verify username/email and password

func VerifyUserActiveCode

func VerifyUserActiveCode(user *models.User, code string) bool

verify active code when active account

func VerifyUserResetPwdCode

func VerifyUserResetPwdCode(user *models.User, code string) bool

verify code when reset password

func WriteRememberCookie

func WriteRememberCookie(user *models.User, ctx *context.Context)

Types

type ForgotForm

type ForgotForm struct {
	Email string       `valid:"Required;Email;MaxSize(80)"`
	User  *models.User `form:"-"`
}

Forgot form

func (*ForgotForm) Helps

func (form *ForgotForm) Helps() map[string]string

func (*ForgotForm) Labels

func (form *ForgotForm) Labels() map[string]string

func (*ForgotForm) Valid

func (form *ForgotForm) Valid(v *validation.Validation)

type LoginForm

type LoginForm struct {
	UserName string `valid:"Required"`
	Password string `form:"type(password)" valid:"Required"`
	Remember bool
}

Login form

func (*LoginForm) Labels

func (form *LoginForm) Labels() map[string]string

type OAuthLoginForm

type OAuthLoginForm struct {
	UserName string `valid:"Required"`
	Password string `form:"type(password)" valid:"Required"`
}

OAuth connect Login form

func (*OAuthLoginForm) Labels

func (form *OAuthLoginForm) Labels() map[string]string

type OAuthRegisterForm

type OAuthRegisterForm struct {
	UserName   string      `valid:"Required;AlphaDash;MinSize(5);MaxSize(30)"`
	Email      string      `valid:"Required;Email;MaxSize(80)"`
	Password   string      `form:"type(password)" valid:"Required;MinSize(4);MaxSize(30)"`
	PasswordRe string      `form:"type(password)" valid:"Required;MinSize(4);MaxSize(30)"`
	Locale     i18n.Locale `form:"-"`
}

OAuth connect Register form

func (*OAuthRegisterForm) Helps

func (form *OAuthRegisterForm) Helps() map[string]string

func (*OAuthRegisterForm) Labels

func (form *OAuthRegisterForm) Labels() map[string]string

func (*OAuthRegisterForm) Placeholders

func (form *OAuthRegisterForm) Placeholders() map[string]string

func (*OAuthRegisterForm) Valid

func (form *OAuthRegisterForm) Valid(v *validation.Validation)

type PasswordForm

type PasswordForm struct {
	PasswordOld string       `form:"type(password)" valid:"Required"`
	Password    string       `form:"type(password)" valid:"Required;MinSize(4);MaxSize(30)"`
	PasswordRe  string       `form:"type(password)" valid:"Required;MinSize(4);MaxSize(30)"`
	User        *models.User `form:"-"`
}

Change password form

func (*PasswordForm) Labels

func (form *PasswordForm) Labels() map[string]string

func (*PasswordForm) Placeholders

func (form *PasswordForm) Placeholders() map[string]string

func (*PasswordForm) Valid

func (form *PasswordForm) Valid(v *validation.Validation)

type ProfileForm

type ProfileForm struct {
	NickName    string                  `valid:"Required;MaxSize(30)"`
	Url         string                  `valid:"MaxSize(100)"`
	Company     string                  `valid:"MaxSize(30)"`
	Location    string                  `valid:"MaxSize(30)"`
	Info        string                  `form:"type(textarea)" valid:"MaxSize(255)"`
	Email       string                  `valid:"Required;Email;MaxSize(100)"`
	PublicEmail bool                    `valid:""`
	GrEmail     string                  `valid:"Required;MaxSize(80)"`
	Github      string                  `valid:"MaxSize(30)"`
	Twitter     string                  `valid:"MaxSize(30)"`
	Google      string                  `valid:"MaxSize(30)"`
	Weibo       string                  `valid:"MaxSize(30)"`
	Linkedin    string                  `valid:"MaxSize(30)"`
	Facebook    string                  `valid:"MaxSize(30)"`
	Lang        int                     `form:"type(select);attr(rel,select2)" valid:""`
	LangAdds    models.SliceStringField `form:"type(select);attr(rel,select2);attr(multiple,multiple)" valid:""`
	Locale      i18n.Locale             `form:"-"`
}

Settings Profile form

func (*ProfileForm) Helps

func (form *ProfileForm) Helps() map[string]string

func (*ProfileForm) Labels

func (form *ProfileForm) Labels() map[string]string

func (*ProfileForm) LangAddsSelectData

func (form *ProfileForm) LangAddsSelectData() [][]string

func (*ProfileForm) LangSelectData

func (form *ProfileForm) LangSelectData() [][]string

func (*ProfileForm) Placeholders

func (form *ProfileForm) Placeholders() map[string]string

func (*ProfileForm) SaveUserProfile

func (form *ProfileForm) SaveUserProfile(user *models.User) error

func (*ProfileForm) SetFromUser

func (form *ProfileForm) SetFromUser(user *models.User)

func (*ProfileForm) Valid

func (form *ProfileForm) Valid(v *validation.Validation)

type RegisterForm

type RegisterForm struct {
	UserName   string      `valid:"Required;AlphaDash;MinSize(5);MaxSize(30)"`
	Email      string      `valid:"Required;Email;MaxSize(80)"`
	Password   string      `form:"type(password)" valid:"Required;MinSize(4);MaxSize(30)"`
	PasswordRe string      `form:"type(password)" valid:"Required;MinSize(4);MaxSize(30)"`
	Captcha    string      `form:"type(captcha)" valid:"Required"`
	CaptchaId  string      `form:"type(empty)"`
	Locale     i18n.Locale `form:"-"`
}

Register form

func (*RegisterForm) Helps

func (form *RegisterForm) Helps() map[string]string

func (*RegisterForm) Labels

func (form *RegisterForm) Labels() map[string]string

func (*RegisterForm) Placeholders

func (form *RegisterForm) Placeholders() map[string]string

func (*RegisterForm) Valid

func (form *RegisterForm) Valid(v *validation.Validation)

type ResetPwdForm

type ResetPwdForm struct {
	Password   string `form:"type(password)" valid:"Required;MinSize(4);MaxSize(30)"`
	PasswordRe string `form:"type(password)" valid:"Required;MinSize(4);MaxSize(30)"`
}

Reset password form

func (*ResetPwdForm) Labels

func (form *ResetPwdForm) Labels() map[string]string

func (*ResetPwdForm) Placeholders

func (form *ResetPwdForm) Placeholders() map[string]string

func (*ResetPwdForm) Valid

func (form *ResetPwdForm) Valid(v *validation.Validation)

type UserAdminForm

type UserAdminForm struct {
	Create      bool                    `form:"-"`
	Id          int                     `form:"-"`
	UserName    string                  `valid:"Required;AlphaDash;MinSize(5);MaxSize(30)"`
	Email       string                  `valid:"Required;Email;MaxSize(100)"`
	PublicEmail bool                    ``
	NickName    string                  `valid:"Required;MaxSize(30)"`
	Url         string                  `valid:"MaxSize(100)"`
	Company     string                  `valid:"MaxSize(30)"`
	Location    string                  `valid:"MaxSize(30)"`
	Info        string                  `form:"type(textarea)" valid:"MaxSize(255)"`
	GrEmail     string                  `valid:"Required;MaxSize(80)"`
	Github      string                  `valid:"MaxSize(30)"`
	Twitter     string                  `valid:"MaxSize(30)"`
	Google      string                  `valid:"MaxSize(30)"`
	Weibo       string                  `valid:"MaxSize(30)"`
	Linkedin    string                  `valid:"MaxSize(30)"`
	Facebook    string                  `valid:"MaxSize(30)"`
	Followers   int                     ``
	Following   int                     ``
	IsAdmin     bool                    ``
	IsActive    bool                    ``
	IsForbid    bool                    ``
	Lang        int                     `form:"type(select);attr(rel,select2)" valid:""`
	LangAdds    models.SliceStringField `form:"type(select);attr(rel,select2);attr(multiple,multiple)" valid:""`
}

func (*UserAdminForm) Helps

func (form *UserAdminForm) Helps() map[string]string

func (*UserAdminForm) Labels

func (form *UserAdminForm) Labels() map[string]string

func (*UserAdminForm) LangAddsSelectData

func (form *UserAdminForm) LangAddsSelectData() [][]string

func (*UserAdminForm) LangSelectData

func (form *UserAdminForm) LangSelectData() [][]string

func (*UserAdminForm) SetFromUser

func (form *UserAdminForm) SetFromUser(user *models.User)

func (*UserAdminForm) SetToUser

func (form *UserAdminForm) SetToUser(user *models.User)

func (*UserAdminForm) Valid

func (form *UserAdminForm) Valid(v *validation.Validation)

Jump to

Keyboard shortcuts

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