예제 #1
0
func (model *UserAdminModel) LangAddsSelectData() [][]string {
	langs := setting.Langs
	data := make([][]string, 0, len(langs))
	for i, lang := range langs {
		data = append(data, []string{lang, utils.ToStr(i)})
	}
	return data
}
예제 #2
0
func (form *ProfileForm) LangAddsSelectData() [][]string {
	langs := setting.Langs
	data := make([][]string, 0, len(langs))
	for i, lang := range langs {
		data = append(data, []string{lang, utils.ToStr(i)})
	}
	return data
}
예제 #3
0
// create a time limit code for user reset password
func (this *UserService) CreateUserResetPwdCode(u *user.User, startInf interface{}) string {
	minutes := setting.ResetPwdCodeLives
	data := utils.ToStr(u.Id) + u.Email + u.Username + u.Password + u.PasswordSalt + u.LastActivityDate.String()
	code := utils.CreateTimeLimitCode(data, minutes, startInf)

	// add tail hex username
	code += hex.EncodeToString([]byte(u.Username))
	return code
}
예제 #4
0
// verify code when reset password
func (this *UserService) VerifyUserResetPwdCode(u *user.User, code string) bool {
	minutes := setting.ResetPwdCodeLives

	if this.getVerifyUser(u, code) {
		// time limit code
		prefix := code[:utils.TimeLimitCodeLength]
		data := utils.ToStr(u.Id) + u.Email + u.Username + u.Password + u.PasswordSalt + u.LastActivityDate.String()

		return utils.VerifyTimeLimitCode(data, minutes, prefix)
	}

	return false
}
예제 #5
0
파일: base.go 프로젝트: thanzen/identity
// check flash redirect, ensure browser redirect to uri and display flash message.
func (this *BaseController) CheckFlashRedirect(value string) (match bool, redirect bool) {
	v := this.GetSession("on_redirect")
	if params, ok := v.([]interface{}); ok {
		if len(params) != 5 {
			this.EndFlashRedirect()
			return match, redirect
		}
		uri := utils.ToStr(params[0])
		code := 302
		if c, ok := params[1].(int); ok {
			if c/100 == 3 {
				code = c
			}
		}
		flag := utils.ToStr(params[2])
		flagVal := utils.ToStr(params[3])
		times := 0
		if v, ok := params[4].(int); ok {
			times = v
		}

		times += 1
		if times > 3 {
			// if max retry times reached then end
			this.EndFlashRedirect()
			return match, redirect
		}

		// match uri or flash flag
		if uri == value || flag == value {
			match = true
		} else {
			// if no match then continue redirect
			this.FlashRedirect(uri, code, flag, flagVal, times)
			redirect = true
		}
	}
	return match, redirect
}