예제 #1
0
func (manager *Manager) NewEmailAddressValidationInformation(username string, email string) (info *EmailAddressValidationInformation, err error) {
	info = &EmailAddressValidationInformation{CreatedAt: time.Now(), Username: username, EmailAddress: email}
	info.Key, err = tools.GenerateRandomString()
	if err != nil {
		return
	}
	info.Secret, err = tools.GenerateRandomString()
	if err != nil {
		return
	}
	return
}
예제 #2
0
// NewResetToken get new reset token
func (pwm *Manager) NewResetToken(username string) (token *ResetToken, err error) {
	tokenstring, err := tools.GenerateRandomString()
	if err != nil {
		return
	}
	token = &ResetToken{Token: tokenstring, CreatedAt: time.Now(), Username: username}
	return
}
예제 #3
0
func (manager *Manager) NewPhonenumberValidationInformation(username string, phonenumber user.Phonenumber) (info *PhonenumberValidationInformation, err error) {
	info = &PhonenumberValidationInformation{CreatedAt: time.Now(), Username: username, Phonenumber: phonenumber.Phonenumber}
	info.Key, err = tools.GenerateRandomString()
	if err != nil {
		return
	}
	numbercode, err := rand.Int(rand.Reader, big.NewInt(999999))
	if err != nil {
		return
	}
	info.SMSCode = fmt.Sprintf("%06d", numbercode)
	return
}
예제 #4
0
func newLoginSessionInformation() (sessionInformation *loginSessionInformation, err error) {
	sessionInformation = &loginSessionInformation{CreatedAt: time.Now()}
	sessionInformation.SessionKey, err = tools.GenerateRandomString()
	if err != nil {
		return
	}
	numbercode, err := rand.Int(rand.Reader, big.NewInt(999999))
	if err != nil {
		return
	}
	sessionInformation.SMSCode = fmt.Sprintf("%06d", numbercode)
	return
}