auth

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Index

Constants

This section is empty.

Variables

View Source
var BindingEmailRouter = router.Handler(func(c router.Context) {
	var (
		input BindingEmailParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return BindingEmail(helper.NewContext(&c), input)
	})
})
View Source
var BindingPhoneRouter = router.Handler(func(c router.Context) {
	var (
		input BindingPhoneParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return BindingPhone(helper.NewContext(&c), input)
	})
})
View Source
var BindingWechatRouter = router.Handler(func(c router.Context) {
	var (
		input BindingWechatMiniAppParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return BindingWechat(helper.NewContext(&c), input)
	})
})
View Source
var QRCodeLoginCheckRouter = router.Handler(func(c router.Context) {
	var (
		input QRCodeCheckParams
	)
	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return QRCodeLoginCheck(helper.NewContext(&c), input)
	})
})
View Source
var QRCodeLoginRouter = router.Handler(func(c router.Context) {
	c.ResponseFunc(nil, func() schema.Response {
		return QRCodeLogin(helper.NewContext(&c))
	})
})
View Source
var ResetPasswordRouter = router.Handler(func(c router.Context) {
	var (
		input ResetPasswordParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return ResetPassword(input)
	})
})
View Source
var SendEmailAuthCodeRouter = router.Handler(func(c router.Context) {
	var (
		input SendEmailAuthCodeParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SendEmailAuthCode(helper.NewContext(&c), input)
	})
})
View Source
var SendPhoneAuthCodeRouter = router.Handler(func(c router.Context) {
	var (
		input SendPhoneAuthCodeParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SendPhoneAuthCode(helper.NewContext(&c), input)
	})
})
View Source
var SignInRouter = router.Handler(func(c router.Context) {
	var (
		input SignInParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SignIn(helper.NewContext(&c), input)
	})
})
View Source
var SignInWithEmailRouter = router.Handler(func(c router.Context) {
	var (
		input SignInWithEmailParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SignInWithEmail(helper.NewContext(&c), input)
	})
})
View Source
var SignInWithOAuthRouter = router.Handler(func(c router.Context) {
	var (
		input SignInWithOAuthParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SignInWithOAuth(helper.NewContext(&c), input)
	})
})
View Source
var SignInWithPhoneRouter = router.Handler(func(c router.Context) {
	var (
		input SignInWithPhoneParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SignInWithPhone(helper.NewContext(&c), input)
	})
})
View Source
var SignInWithWechatRouter = router.Handler(func(c router.Context) {
	var (
		input SignInWithWechatParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SignInWithWechat(helper.NewContext(&c), input)
	})
})
View Source
var SignUpWithEmailActionRouter = router.Handler(func(c router.Context) {
	var (
		input SignUpWithEmailActionParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SignUpWithEmailAction(input)
	})
})
View Source
var SignUpWithEmailRouter = router.Handler(func(c router.Context) {
	var (
		input SignUpWithEmailParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SignUpWithEmail(input)
	})
})
View Source
var SignUpWithPhoneRouter = router.Handler(func(c router.Context) {
	var (
		input SignUpWithPhoneParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SignUpWithPhone(input)
	})
})
View Source
var SignUpWithUsernameRouter = router.Handler(func(c router.Context) {
	var (
		input SignUpWithUsernameParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return SignUpWithUsername(input)
	})
})
View Source
var UnbindingEmailRouter = router.Handler(func(c router.Context) {
	var (
		input UnbindingEmailParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return UnbindingEmail(helper.NewContext(&c), input)
	})
})
View Source
var UnbindingPhoneRouter = router.Handler(func(c router.Context) {
	var (
		input UnbindingPhoneParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return UnbindingPhone(helper.NewContext(&c), input)
	})
})
View Source
var UnbindingWechatRouter = router.Handler(func(c router.Context) {
	var (
		input UnbindingWechatParams
	)

	c.ResponseFunc(c.ShouldBindJSON(&input), func() schema.Response {
		return UnbindingWechat(helper.NewContext(&c), input)
	})
})

Functions

func BindingEmail

func BindingEmail(c helper.Context, input BindingEmailParams) (res schema.Response)

绑定邮箱

func BindingPhone

func BindingPhone(c helper.Context, input BindingPhoneParams) (res schema.Response)

绑定手机号

func BindingWechat

func BindingWechat(c helper.Context, input BindingWechatMiniAppParams) (res schema.Response)

绑定微信

func CreateUserTx

func CreateUserTx(tx *gorm.DB, userInfo *model.User, inviterCode *string) (err error)

创建用户帐号,包括创建的邀请码,钱包数据等,继承到一起

func GenerateAuthCode

func GenerateAuthCode() string

func QRCodeLogin added in v0.7.0

func QRCodeLogin(c helper.Context) (res schema.Response)

func QRCodeLoginCheck added in v0.7.0

func QRCodeLoginCheck(c helper.Context, input QRCodeCheckParams) (res schema.Response)

func ResetPassword

func ResetPassword(input ResetPasswordParams) (res schema.Response)

func SendEmailAuthCode

func SendEmailAuthCode(c helper.Context, input SendEmailAuthCodeParams) (res schema.Response)

发送邮箱验证码 (不需要登陆)

func SendPhoneAuthCode

func SendPhoneAuthCode(c helper.Context, input SendPhoneAuthCodeParams) (res schema.Response)

发送手机验证码 (不需要登陆)

func SignIn

func SignIn(c helper.Context, input SignInParams) (res schema.Response)

普通帐号登陆

func SignInWithEmail

func SignInWithEmail(c helper.Context, input SignInWithEmailParams) (res schema.Response)

邮箱 + 验证码登陆

func SignInWithOAuth

func SignInWithOAuth(c helper.Context, input SignInWithOAuthParams) (res schema.Response)

使用 oAuth 认证方式登陆

func SignInWithPhone

func SignInWithPhone(c helper.Context, input SignInWithPhoneParams) (res schema.Response)

手机 + 验证码登陆

func SignInWithWechat

func SignInWithWechat(c helper.Context, input SignInWithWechatParams) (res schema.Response)

使用微信小程序登陆

func SignUpWithEmail

func SignUpWithEmail(input SignUpWithEmailParams) (res schema.Response)

使用邮箱注册

func SignUpWithEmailAction

func SignUpWithEmailAction(input SignUpWithEmailActionParams) (res schema.Response)

使用邮箱登陆 (发送邮件)

func SignUpWithPhone

func SignUpWithPhone(input SignUpWithPhoneParams) (res schema.Response)

使用手机注册

func SignUpWithUsername

func SignUpWithUsername(input SignUpWithUsernameParams) (res schema.Response)

使用用户名注册

func UnbindingEmail

func UnbindingEmail(c helper.Context, input UnbindingEmailParams) (res schema.Response)

解除邮箱绑定

func UnbindingPhone

func UnbindingPhone(c helper.Context, input UnbindingPhoneParams) (res schema.Response)

解除手机绑定

func UnbindingWechat

func UnbindingWechat(c helper.Context, input UnbindingWechatParams) (res schema.Response)

解除微信绑定

Types

type BindingEmailParams

type BindingEmailParams struct {
	Email string `json:"email" validate:"required,email,max=36" comment:"邮箱"` // 邮箱
	Code  string `json:"code" validate:"required,len=6" comment:"验证码"`        // 邮箱收到的验证码
}

type BindingPhoneParams

type BindingPhoneParams struct {
	Phone string `json:"phone" validate:"required,numeric,len=11" comment:"手机号"` // 手机号
	Code  string `json:"code" validate:"required,len=6" comment:"验证码"`           // 手机收到的验证码
}

type BindingWechatMiniAppParams

type BindingWechatMiniAppParams struct {
	Code string `json:"code" validate:"required,max=255" comment:"微信授权代码"` // 微信小程序调用 wx.login() 之后,返回的 code
}

type QRCodeBody added in v0.7.0

type QRCodeBody struct {
	SessionID string `json:"session_id"` // 会话 ID
	ExpiredAt string `json:"expired_at"` // 会话过期时间
}

type QRCodeCheckParams added in v0.7.0

type QRCodeCheckParams struct {
	Url      string `json:"url" validate:"required" comment:"URL"`
	Duration *int64 `json:"duration" validate:"omitempty,int" comment:"持续时间"`
}

type QRCodeEntry added in v0.7.0

type QRCodeEntry struct {
	OS      string  `json:"os"`                // 操作系统
	Browser string  `json:"browser"`           // 浏览器名称
	Version string  `json:"version"`           // 浏览器版本
	Ip      string  `json:"ip"`                // IP 地址
	UserID  *string `json:"user_id,omitempty"` // 对应的 user ID
}

type ResetPasswordParams

type ResetPasswordParams struct {
	Code        string `json:"code" validate:"required" comment:"激活码"`
	NewPassword string `json:"new_password" validate:"required,max=32" comment:"新密码"`
}

type SendEmailAuthCodeParams

type SendEmailAuthCodeParams struct {
	Email string `json:"email" validate:"required,email" comment:"邮箱"`
}

type SendPhoneAuthCodeParams

type SendPhoneAuthCodeParams struct {
	Phone string `json:"phone" validate:"required,numeric,len=11" comment:"手机号"`
}

type SignInParams

type SignInParams struct {
	Account  string `json:"account" validate:"required,max=36" comment:"帐号"`
	Password string `json:"password" validate:"required,max=32" comment:"密码"`
	Duration *int64 `json:"duration" validate:"omitempty,number,gt=0" comment:"有效时间"`
}

type SignInWithEmailParams

type SignInWithEmailParams struct {
	Email    string `json:"email" validate:"required,email" comment:"邮箱"`
	Code     string `json:"code" validate:"required" comment:"验证码"`
	Duration *int64 `json:"duration" validate:"omitempty,number,gt=0" comment:"有效时间"`
}

type SignInWithOAuthParams

type SignInWithOAuthParams struct {
	Code     string `json:"code" validate:"required" comment:"oAuth授权代码"` // oAuth 授权之后回调返回的 code
	Duration *int64 `json:"duration" validate:"omitempty,number,gt=0" comment:"有效时间"`
}

type SignInWithPhoneParams

type SignInWithPhoneParams struct {
	Phone    string `json:"phone" validate:"required,numeric,len=11" comment:"手机号"`
	Code     string `json:"code" validate:"required" comment:"验证码"`
	Duration *int64 `json:"duration" validate:"omitempty,number,gt=0" comment:"有效时间"`
}

type SignInWithWechatParams

type SignInWithWechatParams struct {
	Code     string `json:"code" validate:"required" comment:"微信授权代码"` // 微信小程序授权之后返回的 code
	Duration *int64 `json:"duration" validate:"omitempty,number,gt=0" comment:"有效时间"`
}

type SignUpWithEmailActionParams

type SignUpWithEmailActionParams struct {
	Email string `json:"email" validate:"required,email,max=255" comment:"邮箱"` // 邮箱
}

type SignUpWithEmailParams

type SignUpWithEmailParams struct {
	Email      string  `json:"email" validate:"required,email,max=255" comment:"邮箱"` // 邮箱
	Password   string  `json:"password" validate:"required,max=32" comment:"密码"`     // 密码
	Code       string  `json:"code" validate:"required" comment:"验证码"`               // 邮箱验证码
	InviteCode *string `json:"invite_code" validate:"omitempty,len=8" comment:"邀请码"` // 邀请码
}

type SignUpWithPhoneParams

type SignUpWithPhoneParams struct {
	Phone      string  `json:"phone" validate:"required,numeric,len=11" comment:"手机号"` // 手机号
	Code       string  `json:"code" validate:"required" comment:"验证码"`                 // 短信验证码
	InviteCode *string `json:"invite_code" validate:"omitempty,len=8" comment:"邀请码"`   // 邀请码
}

type SignUpWithUsernameParams

type SignUpWithUsernameParams struct {
	Username   string  `json:"username" validate:"required,max=32" comment:"用户名"`    // 用户名
	Password   string  `json:"password" validate:"required,max=32" comment:"密码"`     // 密码
	InviteCode *string `json:"invite_code" validate:"omitempty,len=8" comment:"邀请码"` // 邀请码
}

type UnbindingEmailParams

type UnbindingEmailParams struct {
	Code string `json:"code" validate:"required" comment:"验证码"` // 解除邮箱绑定前,需要发送邮箱验证码验证
}

type UnbindingPhoneParams

type UnbindingPhoneParams struct {
	Code string `json:"code" validate:"required" comment:"验证码"` // 解除手机号绑定前,需要发送手机验证码验证
}

type UnbindingWechatParams

type UnbindingWechatParams struct {
	Code string `json:"code" validate:"required" comment:"验证码"` // 验证码,如果帐号已绑定手机,则为手机号收到的验证码,如果有为邮箱,则用邮箱收到的验证码,否则使用 `wx.login()` 返回的 code
}

type WechatCompleteParams

type WechatCompleteParams struct {
	Code     string  `json:"code" validate:"required" comment:"微信授权代码"`               // 微信小程序授权之后返回的 code
	Phone    *string `json:"phone" validate:"omitempty,numeric,len=11" comment:"手机号"` // 手机号
	Username *string `json:"username" validate:"omitempty,max=32" comment:"用户名"`      // 用户名
}

Jump to

Keyboard shortcuts

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