Mercurial > gemma
comparison pkg/auth/opendb.go @ 447:62c909dd3098
Only allow log in if user has at least one of the roles 'sys_admin', 'waterway_admin', 'waterway_user'.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 21 Aug 2018 18:29:34 +0200 |
parents | ffdb507d5b42 |
children | a7dc68d8e22f |
comparison
equal
deleted
inserted
replaced
446:659c04feb2dc | 447:62c909dd3098 |
---|---|
42 | 42 |
43 const InvalidRoleCharacters = `\"':;` | 43 const InvalidRoleCharacters = `\"':;` |
44 | 44 |
45 var ErrInvalidRoleCharacters = errors.New("rolename contains invalid character") | 45 var ErrInvalidRoleCharacters = errors.New("rolename contains invalid character") |
46 | 46 |
47 func AllOtherRoles(user, password string) ([]string, error) { | 47 func AllOtherRoles(user, password string) (Roles, error) { |
48 db, err := OpenDB(user, password) | 48 db, err := OpenDB(user, password) |
49 if err != nil { | 49 if err != nil { |
50 return nil, err | 50 return nil, err |
51 } | 51 } |
52 defer db.Close() | 52 defer db.Close() |
54 if err != nil { | 54 if err != nil { |
55 return nil, err | 55 return nil, err |
56 } | 56 } |
57 defer rows.Close() | 57 defer rows.Close() |
58 | 58 |
59 roles := []string{} // explicit empty by intention. | 59 roles := Roles{} // explicit empty by intention. |
60 | 60 |
61 for rows.Next() { | 61 for rows.Next() { |
62 var role string | 62 var role string |
63 if err := rows.Scan(&role); err != nil { | 63 if err := rows.Scan(&role); err != nil { |
64 return nil, err | 64 return nil, err |