Code review (round 1)
This commit is contained in:
parent
7706bd9845
commit
b37cf02a6e
12 changed files with 78 additions and 23 deletions
|
@ -40,7 +40,7 @@ func (u *User) Admin() bool {
|
|||
|
||||
// User returns true if the user is a regular user, not an admin
|
||||
func (u *User) User() bool {
|
||||
return !u.Admin()
|
||||
return u != nil && u.Role == RoleUser
|
||||
}
|
||||
|
||||
// Auther is an interface for authentication and authorization
|
||||
|
|
13
user/types_test.go
Normal file
13
user/types_test.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPermission(t *testing.T) {
|
||||
require.Equal(t, PermissionReadWrite, NewPermission(true, true))
|
||||
require.Equal(t, PermissionRead, NewPermission(true, false))
|
||||
require.Equal(t, PermissionWrite, NewPermission(false, true))
|
||||
require.Equal(t, PermissionDenyAll, NewPermission(false, false))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue