File tree Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ public function getTokenList(Request $request): JsonResponse
90
90
*/
91
91
public function generateTokenSymbol (Request $ request ): JsonResponse
92
92
{
93
- $ this ->authenticatorService ->checkAdminRights ($ this ->getApiToken ($ request ));
93
+ $ this ->authenticatorService ->checkHydratorRights ($ this ->getApiToken ($ request ));
94
94
95
95
return $ this ->defiService ->generateTokenSymbol ();
96
96
}
@@ -112,7 +112,7 @@ public function generateTokenSymbol(Request $request): JsonResponse
112
112
*/
113
113
public function generateLpPair (Request $ request ): JsonResponse
114
114
{
115
- $ this ->authenticatorService ->checkAdminRights ($ this ->getApiToken ($ request ));
115
+ $ this ->authenticatorService ->checkHydratorRights ($ this ->getApiToken ($ request ));
116
116
117
117
return $ this ->defiService ->generateLpPairToken ();
118
118
}
Original file line number Diff line number Diff line change @@ -35,6 +35,22 @@ public function checkAdminRights(?string $apiKey)
35
35
}
36
36
}
37
37
38
+ /**
39
+ * Check hydrator rights.
40
+ *
41
+ * @param string|null $apiKey
42
+ */
43
+ public function checkHydratorRights (?string $ apiKey )
44
+ {
45
+ if (!empty ($ apiKey )) {
46
+ $ application = $ this ->getApplicationByToken ($ apiKey );
47
+ }
48
+
49
+ if (empty ($ apiKey ) || !$ this ->applicationHaveHydratorRights ($ application )) {
50
+ throw new HttpException (Response::HTTP_FORBIDDEN , "Unauthorized " );
51
+ }
52
+ }
53
+
38
54
/**
39
55
* Get application by token.
40
56
*
@@ -72,6 +88,18 @@ public function applicationHaveAdminRights(Application $application): bool
72
88
return in_array ("ROLE_ADMIN " , $ application ->getUser ()->getRoles ());
73
89
}
74
90
91
+ /**
92
+ * Check if Application have hydrator rights.
93
+ *
94
+ * @param Application $application
95
+ *
96
+ * @return bool
97
+ */
98
+ public function applicationHaveHydratorRights (Application $ application ): bool
99
+ {
100
+ return in_array ("ROLE_HYDRATOR " , $ application ->getUser ()->getRoles ());
101
+ }
102
+
75
103
/**
76
104
* Check user authentication.
77
105
*
Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ public function userRegistration(Request $request): array
41
41
case 'isFreemium ' :
42
42
array_push ($ roles , "ROLE_FREEMIUM " );
43
43
break ;
44
+ case 'isHydrator ' :
45
+ array_push ($ roles , "ROLE_HYDRATOR " );
46
+ break ;
44
47
}
45
48
46
49
$ user = $ this ->checkUserExistence ($ request ->get ('email ' ));
Original file line number Diff line number Diff line change 41
41
Freemium
42
42
</label >
43
43
</div >
44
+ <div class =" form-check form-check-inline" >
45
+ <input class =" form-check-input" type =" radio" value =" isHydrator" name =" quotaRole" id =" isHydrator" >
46
+ <label class =" form-check-label" for =" isHydrator" >
47
+ Hydrator
48
+ </label >
49
+ </div >
44
50
</div >
45
51
<div class =" form-group" >
46
52
<input type =" text" class =" form-control" id =" formGroupUsername" name =" username" placeholder =" Username" required >
You can’t perform that action at this time.
0 commit comments