add redirect for accoun linking
This commit is contained in:
parent
c4a92ebf12
commit
1adb8c6e8a
1
.gitignore
vendored
1
.gitignore
vendored
@ -159,3 +159,4 @@ fabric.properties
|
|||||||
.ionide
|
.ionide
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,goland,go
|
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,goland,go
|
||||||
|
main
|
||||||
|
@ -23,13 +23,13 @@ func (c *WebhookController) WebhookCreate(ctx *fiber.Ctx) error {
|
|||||||
return ctx.Status(http.StatusForbidden).SendString("Access denied")
|
return ctx.Status(http.StatusForbidden).SendString("Access denied")
|
||||||
}
|
}
|
||||||
|
|
||||||
accountID, err := tools.DeserializeProtobufMessage(state)
|
accountID, redirectURL, err := tools.DeserializeProtobufMessage(state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Error("error Deserialize Protobuf Message", zap.Error(err))
|
c.logger.Error("error Deserialize Protobuf Message", zap.Error(err))
|
||||||
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
||||||
}
|
}
|
||||||
|
|
||||||
if accountID == nil {
|
if accountID == "" {
|
||||||
c.logger.Error("error account id do not be nil", zap.Error(err))
|
c.logger.Error("error account id do not be nil", zap.Error(err))
|
||||||
return ctx.Status(fiber.StatusBadRequest).SendString("nil account id")
|
return ctx.Status(fiber.StatusBadRequest).SendString("nil account id")
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ func (c *WebhookController) WebhookCreate(ctx *fiber.Ctx) error {
|
|||||||
req := service.ParamsWebhookCreate{
|
req := service.ParamsWebhookCreate{
|
||||||
Code: code,
|
Code: code,
|
||||||
Referer: referer,
|
Referer: referer,
|
||||||
AccountID: *accountID,
|
AccountID: accountID,
|
||||||
FromWidget: fromWidget,
|
FromWidget: fromWidget,
|
||||||
Platform: platform,
|
Platform: platform,
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ func (c *WebhookController) WebhookCreate(ctx *fiber.Ctx) error {
|
|||||||
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.SendStatus(fiber.StatusOK)
|
return ctx.Redirect(redirectURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo проверить надо
|
// todo проверить надо
|
||||||
|
@ -5,13 +5,18 @@ import (
|
|||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DeserializeProtobufMessage(protobufMessage string) (*string, error) {
|
func DeserializeProtobufMessage(protobufMessage string) (string, string, error) {
|
||||||
msg := socialauth.Message{}
|
msg := socialauth.Message{}
|
||||||
|
|
||||||
err := proto.Unmarshal([]byte(protobufMessage), &msg)
|
err := proto.Unmarshal([]byte(protobufMessage), &msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg.AccessToken, nil
|
var accountID string
|
||||||
|
if msg.AccessToken != nil {
|
||||||
|
accountID = *msg.AccessToken
|
||||||
|
}
|
||||||
|
|
||||||
|
return accountID, msg.ReturnURL, nil
|
||||||
}
|
}
|
||||||
|
BIN
main
BIN
main
Binary file not shown.
Loading…
Reference in New Issue
Block a user