File tree Expand file tree Collapse file tree 2 files changed +12
-27
lines changed Expand file tree Collapse file tree 2 files changed +12
-27
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,11 @@ public function addGroup(string ...$groups): self
43
43
continue ;
44
44
}
45
45
46
+ /** @var GroupModel $groupModel */
47
+ $ groupModel = model (GroupModel::class);
48
+
46
49
// make sure it's a valid group
47
- if (! $ this ->isValidGroup ($ group )) {
50
+ if (! $ groupModel ->isValidGroup ($ group )) {
48
51
throw AuthorizationException::forUnknownGroup ($ group );
49
52
}
50
53
@@ -59,18 +62,6 @@ public function addGroup(string ...$groups): self
59
62
return $ this ;
60
63
}
61
64
62
- /**
63
- * @TODO duplicate of UserModel::isValidGroup()
64
- *
65
- * @param non-empty-string $group
66
- */
67
- private function isValidGroup (string $ group ): bool
68
- {
69
- $ allowedGroups = array_keys (setting ('AuthGroups.groups ' ));
70
-
71
- return (bool ) (in_array ($ group , $ allowedGroups , true ));
72
- }
73
-
74
65
/**
75
66
* Removes one or more groups from the user.
76
67
*
@@ -106,8 +97,11 @@ public function syncGroups(string ...$groups): self
106
97
{
107
98
$ this ->populateGroups ();
108
99
100
+ /** @var GroupModel $groupModel */
101
+ $ groupModel = model (GroupModel::class);
102
+
109
103
foreach ($ groups as $ group ) {
110
- if (! $ this ->isValidGroup ($ group )) {
104
+ if (! $ groupModel ->isValidGroup ($ group )) {
111
105
throw AuthorizationException::forUnknownGroup ($ group );
112
106
}
113
107
}
Original file line number Diff line number Diff line change @@ -155,25 +155,16 @@ public function addToDefaultGroup(User $user): void
155
155
{
156
156
$ defaultGroup = setting ('AuthGroups.defaultGroup ' );
157
157
158
- if (empty ($ defaultGroup ) || ! $ this ->isValidGroup ($ defaultGroup )) {
158
+ /** @var GroupModel $groupModel */
159
+ $ groupModel = model (GroupModel::class);
160
+
161
+ if (empty ($ defaultGroup ) || ! $ groupModel ->isValidGroup ($ defaultGroup )) {
159
162
throw new InvalidArgumentException (lang ('Auth.unknownGroup ' , [$ defaultGroup ?? '--not found-- ' ]));
160
163
}
161
164
162
165
$ user ->addGroup ($ defaultGroup );
163
166
}
164
167
165
- /**
166
- * @TODO duplicate of Authorizable::isValidGroup()
167
- *
168
- * @param non-empty-string $group
169
- */
170
- private function isValidGroup (string $ group ): bool
171
- {
172
- $ allowedGroups = array_keys (setting ('AuthGroups.groups ' ));
173
-
174
- return (bool ) (in_array ($ group , $ allowedGroups , true ));
175
- }
176
-
177
168
public function fake (Generator &$ faker ): User
178
169
{
179
170
$ this ->checkReturnType ();
You can’t perform that action at this time.
0 commit comments