refactor: require an api name to be provided and skip if not matched
This commit is contained in:
parent
4a3028f61a
commit
9587ef4941
|
@ -102,13 +102,17 @@ func JWTVerifyToken(token string, domain string, privateKey ed25519.PrivateKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetAuthCookie(jc jape.Context, jwt string, apiName string) {
|
func SetAuthCookie(jc jape.Context, jwt string, apiName string) {
|
||||||
|
if len(apiName) == 0 {
|
||||||
|
panic("apiName is required")
|
||||||
|
}
|
||||||
|
|
||||||
for name, api := range apiRegistry.GetAllAPIs() {
|
for name, api := range apiRegistry.GetAllAPIs() {
|
||||||
routeableApi, ok := api.(router.RoutableAPI)
|
routeableApi, ok := api.(router.RoutableAPI)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(apiName) > 0 && apiName != name {
|
if apiName != name {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,13 +129,17 @@ func SetAuthCookie(jc jape.Context, jwt string, apiName string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func EchoAuthCookie(jc jape.Context, apiName string) {
|
func EchoAuthCookie(jc jape.Context, apiName string) {
|
||||||
|
if len(apiName) == 0 {
|
||||||
|
panic("apiName is required")
|
||||||
|
}
|
||||||
|
|
||||||
for name, api := range apiRegistry.GetAllAPIs() {
|
for name, api := range apiRegistry.GetAllAPIs() {
|
||||||
routeableApi, ok := api.(router.RoutableAPI)
|
routeableApi, ok := api.(router.RoutableAPI)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(apiName) > 0 && apiName != name {
|
if apiName != name {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,13 +176,17 @@ func EchoAuthCookie(jc jape.Context, apiName string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ClearAuthCookie(jc jape.Context, apiName string) {
|
func ClearAuthCookie(jc jape.Context, apiName string) {
|
||||||
|
if len(apiName) == 0 {
|
||||||
|
panic("apiName is required")
|
||||||
|
}
|
||||||
|
|
||||||
for name, api := range apiRegistry.GetAllAPIs() {
|
for name, api := range apiRegistry.GetAllAPIs() {
|
||||||
routeableApi, ok := api.(router.RoutableAPI)
|
routeableApi, ok := api.(router.RoutableAPI)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(apiName) > 0 && apiName != name {
|
if apiName != name {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue