Example #1
0
// get user if key exist in session
func (this *BaseController) GetUserFromSession(u *user.User, sess session.Store) bool {
	id := this.GetUserIdFromSession(sess)
	if id > 0 {
		u.Id = id
		if this.UserService.Read(u) == nil {
			return true
		}
	}

	return false
}
Example #2
0
func (this *AdminApiController) ResetPassword() {
	var ChangePasswordModel = struct {
		Id       int64
		Password string
	}{}
	this.CheckPermission(permissions.UserAdminUpdate)
	var u user.User
	json.Unmarshal(this.Ctx.Input.RequestBody, &ChangePasswordModel)
	u.Id = ChangePasswordModel.Id
	u.Password = ChangePasswordModel.Password
	var err error
	if u.Id > 0 {
		err = this.UserService.SaveNewPassword(&u, u.Password)
		if err != nil {
			this.Ctx.Abort(500, err.Error())
		}
	} else {
		this.Ctx.Abort(500, "invalid user id")
	}
	this.ServeJSON()
}