-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add validations for user invite permission
This validation makes sure only owners can invite other owners.
- Loading branch information
1 parent
ec0cab0
commit 2986a17
Showing
6 changed files
with
105 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/demo/boards2" | ||
) | ||
|
||
const ( | ||
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 | ||
admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 | ||
) | ||
|
||
func init() { | ||
std.TestSetOrigCaller(owner) | ||
} | ||
|
||
func main() { | ||
boards2.InviteMember(admin, boards2.RoleAdmin) | ||
println("ok") | ||
} | ||
|
||
// Output: | ||
// ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/demo/boards2" | ||
) | ||
|
||
const ( | ||
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 | ||
admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 | ||
user = std.Address("g1w4ek2u33ta047h6lta047h6lta047h6ldvdwpn") | ||
) | ||
|
||
func init() { | ||
// Add an admin user | ||
std.TestSetOrigCaller(owner) | ||
boards2.InviteMember(admin, boards2.RoleAdmin) | ||
|
||
// Next call will be done by the admin user | ||
std.TestSetOrigCaller(admin) | ||
} | ||
|
||
func main() { | ||
boards2.InviteMember(user, boards2.RoleOwner) | ||
} | ||
|
||
// Error: | ||
// only owners are allowed to invite other owners |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/r/demo/boards2" | ||
) | ||
|
||
const ( | ||
owner = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1 | ||
admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2 | ||
user = std.Address("g1w4ek2u33ta047h6lta047h6lta047h6ldvdwpn") | ||
) | ||
|
||
func init() { | ||
// Add an admin user | ||
std.TestSetOrigCaller(owner) | ||
boards2.InviteMember(admin, boards2.RoleAdmin) | ||
|
||
// Next call will be done by the admin user | ||
std.TestSetOrigCaller(admin) | ||
} | ||
|
||
func main() { | ||
boards2.InviteMember(user, boards2.RoleAdmin) | ||
println("ok") | ||
} | ||
|
||
// Output: | ||
// ok |