auth

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 20 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 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 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" valid:"required~请输入邮箱"` // 邮箱
	Code  string `json:"code" valid:"required~请输入验证码"` // 邮箱收到的验证码
}

type BindingPhoneParams

type BindingPhoneParams struct {
	Phone string `json:"phone" valid:"required~请输入手机号"` // 手机号
	Code  string `json:"code" valid:"required~请输入验证码"`  // 手机收到的验证码
}

type BindingWechatMiniAppParams

type BindingWechatMiniAppParams struct {
	Code string `json:"code" valid:"required~请输入微信认证码"` // 微信小程序调用 wx.login() 之后,返回的 code
}

type ResetPasswordParams

type ResetPasswordParams struct {
	Code        string `json:"code" valid:"required~请输入激活码"`
	NewPassword string `json:"new_password" valid:"required~请输入新密码"`
}

type SendEmailAuthCodeParams

type SendEmailAuthCodeParams struct {
	Email string `json:"email" valid:"required~请输入邮箱"`
}

type SendPhoneAuthCodeParams

type SendPhoneAuthCodeParams struct {
	Phone string `json:"phone" valid:"required~请输入手机号"`
}

type SignInParams

type SignInParams struct {
	Account  string `json:"account" valid:"required~请输入登陆账号"`
	Password string `json:"password" valid:"required~请输入密码"`
}

type SignInWithEmailParams

type SignInWithEmailParams struct {
	Email string `json:"email" valid:"required~请输入邮箱"`
	Code  string `json:"code" valid:"required~请输入验证码"`
}

type SignInWithOAuthParams

type SignInWithOAuthParams struct {
	Code string `json:"code" valid:"required~请输入授权代码"` // oAuth 授权之后回调返回的 code
}

type SignInWithPhoneParams

type SignInWithPhoneParams struct {
	Phone string `json:"phone" valid:"required~请输入手机号"`
	Code  string `json:"code" valid:"required~请输入验证码"`
}

type SignInWithWechatParams

type SignInWithWechatParams struct {
	Code string `json:"code" valid:"required~请输入微信授权代码"` // 微信小程序授权之后返回的 code
}

type SignUpWithEmailActionParams

type SignUpWithEmailActionParams struct {
	Email string `json:"email" valid:"required~请输入邮箱"` // 邮箱
}

type SignUpWithEmailParams

type SignUpWithEmailParams struct {
	Email      string  `json:"email" valid:"required~请输入邮箱"`    // 邮箱
	Password   string  `json:"password" valid:"required~请输入密码"` // 密码
	Code       string  `json:"code" valid:"required~请输入邮箱验证码"`  // 邮箱验证码
	InviteCode *string `json:"invite_code"`                     // 邀请码
}

type SignUpWithPhoneParams

type SignUpWithPhoneParams struct {
	Phone      string  `json:"phone" valid:"required~请输入手机号"`  // 手机号
	Code       string  `json:"code" valid:"required~请输入手机验证码"` // 短信验证码
	InviteCode *string `json:"invite_code"`                    // 邀请码
}

type SignUpWithUsernameParams

type SignUpWithUsernameParams struct {
	Username   string  `json:"username" valid:"required~请输入用户名"` // 用户名
	Password   string  `json:"password" valid:"required~请输入密码"`  // 密码
	InviteCode *string `json:"invite_code"`                      // 邀请码
}

type UnbindingEmailParams

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

type UnbindingPhoneParams

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

type UnbindingWechatParams

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

type WechatCompleteParams

type WechatCompleteParams struct {
	Code     string  `json:"code" valid:"required~请输入微信授权代码"` // 微信小程序授权之后返回的 code
	Phone    *string `json:"phone"`                           // 手机号
	Username *string `json:"username"`                        // 用户名
}

Jump to

Keyboard shortcuts

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