user

package
v0.0.0-...-795d1ad Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	// unix timestamp
	Created int64 `json:"created"`
	// an email address
	Email string `json:"email"`
	// unique account id
	Id string `json:"id"`
	// Store any custom data you want about your users in this fields.
	Profile map[string]string `json:"profile"`
	// unix timestamp
	Updated int64 `json:"updated"`
	// alphanumeric username
	Username         string `json:"username"`
	VerificationDate int64  `json:"verificationDate"`
	Verified         bool   `json:"verified"`
}

type CreateRequest

type CreateRequest struct {
	// the email address
	Email string `json:"email"`
	// optional account id
	Id string `json:"id"`
	// the user password
	Password string `json:"password"`
	// optional user profile as map<string,string>
	Profile map[string]string `json:"profile"`
	// the username
	Username string `json:"username"`
}

type CreateResponse

type CreateResponse struct {
	Account *Account `json:"account"`
}

type DeleteRequest

type DeleteRequest struct {
	// the account id
	Id string `json:"id"`
}

type DeleteResponse

type DeleteResponse struct {
}

type LoginRequest

type LoginRequest struct {
	// The email address of the user
	Email string `json:"email"`
	// The password of the user
	Password string `json:"password"`
	// The username of the user
	Username string `json:"username"`
}

type LoginResponse

type LoginResponse struct {
	// The session of the logged in  user
	Session *Session `json:"session"`
}

type LogoutRequest

type LogoutRequest struct {
	SessionId string `json:"sessionId"`
}

type LogoutResponse

type LogoutResponse struct {
}

type ReadRequest

type ReadRequest struct {
	// the account email
	Email string `json:"email"`
	// the account id
	Id string `json:"id"`
	// the account username
	Username string `json:"username"`
}

type ReadResponse

type ReadResponse struct {
	Account *Account `json:"account"`
}

type ReadSessionRequest

type ReadSessionRequest struct {
	// The unique session id
	SessionId string `json:"sessionId"`
}

type ReadSessionResponse

type ReadSessionResponse struct {
	Session *Session `json:"session"`
}

type SendVerificationEmailRequest

type SendVerificationEmailRequest struct {
	Email              string `json:"email"`
	FailureRedirectUrl string `json:"failureRedirectUrl"`
	// Display name of the sender for the email. Note: the email address will still be 'support@m3o.com'
	FromName    string `json:"fromName"`
	RedirectUrl string `json:"redirectUrl"`
	Subject     string `json:"subject"`
	// Text content of the email. Don't forget to include the string '$micro_verification_link' which will be replaced by the real verification link
	// HTML emails are not available currently.
	TextContent string `json:"textContent"`
}

type SendVerificationEmailResponse

type SendVerificationEmailResponse struct {
}

type Session

type Session struct {
	// unix timestamp
	Created int64 `json:"created"`
	// unix timestamp
	Expires int64 `json:"expires"`
	// the session id
	Id string `json:"id"`
	// the associated user id
	UserId string `json:"userId"`
}

type UpdatePasswordRequest

type UpdatePasswordRequest struct {
	// confirm new password
	ConfirmPassword string `json:"confirmPassword"`
	// the new password
	NewPassword string `json:"newPassword"`
	// the old password
	OldPassword string `json:"oldPassword"`
	// the account id
	UserId string `json:"userId"`
}

type UpdatePasswordResponse

type UpdatePasswordResponse struct {
}

type UpdateRequest

type UpdateRequest struct {
	// the new email address
	Email string `json:"email"`
	// the account id
	Id string `json:"id"`
	// the user profile as map<string,string>
	Profile map[string]string `json:"profile"`
	// the new username
	Username string `json:"username"`
}

type UpdateResponse

type UpdateResponse struct {
}

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(token string) *UserService

func (*UserService) Create

func (t *UserService) Create(request *CreateRequest) (*CreateResponse, error)

Create a new user account. The email address and username for the account must be unique.

func (*UserService) Delete

func (t *UserService) Delete(request *DeleteRequest) (*DeleteResponse, error)

Delete an account by id

func (*UserService) Login

func (t *UserService) Login(request *LoginRequest) (*LoginResponse, error)

Login using username or email. The response will return a new session for successful login, 401 in the case of login failure and 500 for any other error

func (*UserService) Logout

func (t *UserService) Logout(request *LogoutRequest) (*LogoutResponse, error)

Logout a user account

func (*UserService) Read

func (t *UserService) Read(request *ReadRequest) (*ReadResponse, error)

Read an account by id, username or email. Only one need to be specified.

func (*UserService) ReadSession

func (t *UserService) ReadSession(request *ReadSessionRequest) (*ReadSessionResponse, error)

Read a session by the session id. In the event it has expired or is not found and error is returned.

func (*UserService) SendVerificationEmail

func (t *UserService) SendVerificationEmail(request *SendVerificationEmailRequest) (*SendVerificationEmailResponse, error)

Send a verification email to the user being signed up. Email from will be from 'support@m3o.com', but you can provide the title and contents. The verification link will be injected in to the email as a template variable, $micro_verification_link. Example: 'Hi there, welcome onboard! Use the link below to verify your email: $micro_verification_link' The variable will be replaced with an actual url that will look similar to this: 'https://user.m3o.com/user/verify?token=a-verification-token&rediretUrl=your-redir-url'

func (*UserService) Update

func (t *UserService) Update(request *UpdateRequest) (*UpdateResponse, error)

Update the account username or email

func (*UserService) UpdatePassword

func (t *UserService) UpdatePassword(request *UpdatePasswordRequest) (*UpdatePasswordResponse, error)

Update the account password

func (*UserService) VerifyEmail

func (t *UserService) VerifyEmail(request *VerifyEmailRequest) (*VerifyEmailResponse, error)

Verify the email address of an account from a token sent in an email to the user.

type VerifyEmailRequest

type VerifyEmailRequest struct {
	// The token from the verification email
	Token string `json:"token"`
}

type VerifyEmailResponse

type VerifyEmailResponse struct {
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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