本文整理汇总了Golang中github.com/kidstuff/auth/authmodel.Manager.FindUser方法的典型用法代码示例。如果您正苦于以下问题:Golang Manager.FindUser方法的具体用法?Golang Manager.FindUser怎么用?Golang Manager.FindUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/kidstuff/auth/authmodel.Manager
的用法示例。
在下文中一共展示了Manager.FindUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testManagerDeleteUser
// testManagerDeleteUser check if delete user operation work.
func testManagerDeleteUser(t *testing.T, mngr authmodel.Manager, uid string) {
err := mngr.DeleteUser(uid)
if err != nil {
t.Fatal("delete user failed:", err)
}
_, err = mngr.FindUser(uid)
if err != authmodel.ErrNotFound {
t.Fatal("delete user not work")
}
}
示例2: testManagerDeleteGroup
// testManagerDeleteGroup recieve a group id and a user id who belong to that group.
// After group delettion, check if the group infomation of in user account removed or not.
func testManagerDeleteGroup(t *testing.T, mngr authmodel.Manager, gid, uid string) {
err := mngr.DeleteGroup(gid)
if err != nil {
t.Fatal("delete group failed:", err)
}
u, err := mngr.FindUser(uid)
if err != nil {
t.Fatal("cannot find user:", err)
}
if len(u.Groups) > 0 {
t.Fatal("delete group must remove group info in user")
}
}
示例3: testManagerUpdateUserDetail
// testManagerUpdateUserDetail test update user operation and check the password hash function.
func testManagerUpdateUserDetail(t *testing.T, mngr authmodel.Manager, uid, gid string) {
ps := "testing12345"
app := false
code := map[string]string{"tested": "notyet"}
err := mngr.UpdateUserDetail(uid, &ps, &app, []string{"testing"}, code, nil, []string{gid})
if err != nil {
t.Fatal("cannot update user detail:", err)
}
u, err := mngr.FindUser(uid)
if err != nil {
t.Fatal("Cannot find user:", err)
}
if *u.Approved != app {
t.Fatal("update user approved failed")
}
if len(u.Privileges) != 1 {
t.Fatal("update user privileges failed")
}
if u.Privileges[0] != "testing" {
t.Fatal("update user privileges failed")
}
if u.ConfirmCodes["tested"] != "notyet" {
t.Fatal("update user confirm code failed")
}
if len(u.Groups) != 1 {
t.Fatal("update user group failed")
}
if *u.Groups[0].Id != gid {
t.Fatal("update user group failed")
}
err = mngr.ComparePassword(ps, u.Pwd)
if err != nil {
t.Fatal("password hash error:", err)
}
}
示例4: testManagerAddUserDetail
// testManagerAddUserDetail check if add user operation work
func testManagerAddUserDetail(t *testing.T, mngr authmodel.Manager, gid string) string {
code := map[string]string{"tested": "notyet"}
u, err := mngr.AddUserDetail("[email protected]", "test123edc", true, []string{"testing"}, code, nil, []string{gid})
if err != nil {
t.Fatal("cannot update user detail:", err)
}
u, err = mngr.FindUser(*u.Id)
if err != nil {
t.Fatal("Cannot find user:", err)
}
if *u.Approved != true {
t.Fatal("update user approved failed")
}
if len(u.Privileges) != 1 {
t.Fatal("update user privileges failed")
}
if u.Privileges[0] != "testing" {
t.Fatal("update user privileges failed")
}
if u.ConfirmCodes["tested"] != "notyet" {
t.Fatal("update user confirm code failed")
}
if len(u.Groups) != 1 {
t.Fatal("update user group failed")
}
if *u.Groups[0].Id != gid {
t.Fatal("update user group failed")
}
return *u.Id
}