auth

package
v0.0.0-...-3812866 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewService

func NewService(cfg *common.Config) *iris.Application

func RegisterRoute

func RegisterRoute(app *iris.Application, cors context.Handler, cfg *common.Config)

Types

type AccountModel

type AccountModel struct {
	ID            uint64          `json:"ID"  bson:"_id,omitempty" `
	Username      string          `json:"username"  bson:"username"`
	Password      string          `json:"password" bson:"password"`
	SocialNetwork []SocialNetwork `json:"SocialNetwork" bson:"social_network"`
	ActivatedDate int64           `json:"activated_date" bson:"activated_date"`
	Profile       Profile         `json:"profile" bson:"profile"`
	Status        int             `json:"status" bson:"status"`
}

type ActivateModel

type ActivateModel struct {
	Username     string `json:"username"`
	ActivateCode string `json:"activate_code" bson:"activate_code"`
}

type AuthRepository

type AuthRepository interface {
	SignIn(*SignInModel) (*UserModel, *ProfileModel, error)
	VerifyBySms(mobile string, otpCode string) (*RegisterModel, error)
	VerifyByEmail(email string, activateCode string) (*RegisterModel, error)
	CreateID(registerInfo *RegisterModel, smartID uint64) (*UserProfile, error)
	ReadMailPool(email string) (*EmailProfileModel, error)
	ReadMobilePool(mobile string, code string) (*MobileProfileModel, error)
	UpdateProfileContactWithCombineUser(username string, smartID uint64, contactType int) (bool, error)
	UpdateProfileContact(contact string, smartID uint64, contactType int) (bool, error)
	ReadPassword(string) (*UserModel, error)
	WritePassword(string, string) (bool, error)
	CreateRefreshToken(string, interface{}, time.Duration) (bool, error)
	ReadRefreshToken(string) (string, error)
	ReadOTP(code string) (string, error)
}

func NewAuthRepository

func NewAuthRepository(sess *mgo.Session, redis *db.Redis, cfg *common.Config) AuthRepository

type AuthRoute

type AuthRoute struct {
	common.Context
	Service AuthService
}

func (*AuthRoute) BeforeActivation

func (r *AuthRoute) BeforeActivation(b mvc.BeforeActivation)

func (*AuthRoute) GetActivate

func (r *AuthRoute) GetActivate()

func (*AuthRoute) GetRefreshToken

func (r *AuthRoute) GetRefreshToken(rft string)

func (*AuthRoute) GetUpdateContact

func (r *AuthRoute) GetUpdateContact()

func (*AuthRoute) PostChangePassword

func (r *AuthRoute) PostChangePassword()

func (*AuthRoute) PostCreateNewPassword

func (r *AuthRoute) PostCreateNewPassword()

func (*AuthRoute) PostSignIn

func (r *AuthRoute) PostSignIn()

func (*AuthRoute) PostSocialSignIn

func (r *AuthRoute) PostSocialSignIn()

type AuthService

type AuthService interface {
	SignIn(*SignInModel) (interface{}, error)
	Verify(activate *ActivateModel) (interface{}, error)
	UpdateContact(*UpdateContact) (interface{}, error)
	ChangePassword(*ChangePasswordModel) (bool, error)
	ConfirmVerify(*VerifyContact) (bool, error)
	SignInViaRefreshToken(string) (interface{}, error)
	ForgotPassword(string, string, string) (bool, error)
}

AuthService interface

func NewAuthService

func NewAuthService(repo AuthRepository, conf *common.Config) AuthService

NewAuthService method

type ChangePasswordModel

type ChangePasswordModel struct {
	Username    string `json:"username"`
	OldPassword string `json:"old_password"`
	NewPassword string `json:"new_password"`
}

type EmailProfileModel

type EmailProfileModel struct {
	ID       string `json:"id" bson:"_id,omitempty"`
	SID      uint64 `json:"sid" bson:"sid"`
	Code     string `json:"code" bson:"code"`
	FullName string `json:"full_name" bson:"full_name"`
	Username string `json:"username" bson:"username"`
	Email    string `json:"email" bson:"email"`
	Used     bool   `json:"used" bson:"used"`
}

type ForgotPassword

type ForgotPassword struct {
	Username string `json:"username"`
	Code     string `json:"code"`
	Password string `json:"password"`
}

type MobileProfileModel

type MobileProfileModel struct {
	ID       string `json:"id" bson:"_id,omitempty"`
	SID      uint64 `json:"sid" bson:"sid"`
	Code     string `json:"code" bson:"code"`
	FullName string `json:"full_name" bson:"full_name"`
	Username string `json:"username" bson:"username"`
	Mobile   string `json:"mobile" bson:"mobile"`
	Used     bool   `json:"used" bson:"used"`
}

type OtpModel

type OtpModel struct {
	ID     string        `json:"id"`
	Mobile string        `json:"mobile"`
	TTL    time.Duration `json:"ttl"`
}

type Profile

type Profile struct {
	ID          uint64
	FirstName   string `json:"first_name" bson:"first_name"`
	LastName    string `json:"last_name" bson:"last_name"`
	FullName    string `json:"full_name" bson:"full_name"`
	Gender      int    `json:"gender" bson:"gender"`
	BirthDate   int64  `json:"birth_date" bson:"birth_date"`
	Address     string `json:"address" bson:"address"`
	Avatar      string `json:"avatar" bson:"avatar"`
	Mobile      string `json:"mobile" bson:"mobile"`
	Email       string `json:"email" bson:"email"`
	Cover       string `json:"cover" bson:"cover"`
	CreatedDate int64  `json:"created_date" bson:"created_date"`
	LastUpdate  int64  `json:"last_update" bson:"last_update"`
}

type ProfileModel

type ProfileModel struct {
	ID          uint64 `json:"id"  bson:"_id,omitempty" `
	FirstName   string `json:"first_name" bson:"first_name"`
	LastName    string `json:"last_name" bson:"last_name"`
	FullName    string `json:"full_name" bson:"full_name"`
	Gender      int    `json:"gender" bson:"gender"`
	BirthDate   int64  `json:"birth_date" bson:"birth_date"`
	Address     string `json:"address" bson:"address"`
	Avatar      string `json:"avatar" bson:"avatar"`
	Mobile      string `json:"mobile" bson:"mobile"`
	Email       string `json:"email" bson:"email"`
	Cover       string `json:"cover" bson:"cover"`
	CreatedDate int64  `json:"created_date" bson:"created_date"`
	LastUpdate  int64  `json:"last_update" bson:"last_update"`
}

type RefreshToken

type RefreshToken struct {
	UserName string        `json:"username"`
	Profile  *ProfileModel `json:"profile"`
}

type RegisterModel

type RegisterModel struct {
	ID             string          `json:"ID"  bson:"_id,omitempty" `
	Username       string          `json:"username" bson:"username"`
	Password       string          `json:"password" bson:"password"`
	SocialNetwork  []SocialNetwork `json:"SocialNetwork" bson:"social_network"`
	Profile        Profile         `json:"profile" bson:"profile"`
	RegisteredDate int64           `json:"registered_date" bson:"registered_date"`
	VerifyCode     string          `json:"verify_code" bson:"verify_code"`
	VerifiedDate   int             `json:"verified_date" bson:"verified_date"`
}

type SignInModel

type SignInModel struct {
	Username string `json:"username" bson:"username"`
	Password string `json:"password" bson:"password"`
	System   string `json:"system" bson:"system"`
	Expired  int    `json:"expired"`
}

type SignInResponse

type SignInResponse struct {
	SmartID      uint64 `json:"smart_id"`
	Token        string `json:"token"`
	RefreshToken string `json:"refresh_token"`
}

type SocialNetwork

type SocialNetwork struct {
	Network string `json:"network" bson:"network"`
	Code    string `json:"code" bson:"code"`
}

type SocialNetworkModel

type SocialNetworkModel struct {
	ID            string `json:"id"  bson:"_id,omitempty" `
	Network       string `json:"network" bson:"network"`
	ProfileID     uint64 `json:"profile_id" bson:"profile_id"`
	ActivatedDate int64  `json:"activated_date" bson:"activated_date"`
	Status        int    `json:"status" bson:"status"`
}

type UpdateContact

type UpdateContact struct {
	Contact string `json:"contact"`
	Code    string `json:"code"`
}

type UserModel

type UserModel struct {
	ID            string `json:"id"  bson:"_id,omitempty" `
	Username      string `json:"username"  bson:"username"`
	Password      string `json:"password" bson:"password"`
	ProfileID     uint64 `json:"profile_id" bson:"profile_id"`
	ActivatedDate int64  `json:"activated_date" bson:"activated_date"`
	Status        int    `json:"status" bson:"status"`
}

type UserProfile

type UserProfile struct {
	SmartID       uint64        `json:"smart_id"`
	Username      string        `json:"username"`
	Profile       *ProfileModel `json:"profile"`
	ActivatedDate int64         `json:"activated_date"`
	Status        int           `json:"status"`
}

type VerifyContact

type VerifyContact struct {
	Contact string `json:"contact"`
	Code    string `json:"code"`
}

Jump to

Keyboard shortcuts

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