diff --git a/kite-service/cmd/config/login.go b/kite-service/cmd/config/login.go index e68c1ef..e3c3e13 100644 --- a/kite-service/cmd/config/login.go +++ b/kite-service/cmd/config/login.go @@ -21,8 +21,8 @@ func loginCMD() *cli.Command { Flags: []cli.Flag{ &cli.StringFlag{ Name: "server", - Usage: "The Kite server to deploy to", - Value: "http://localhost:8080", + Usage: "The Kite server to authenticate with", + Value: "https://api.kite.onl", }, }, Action: func(c *cli.Context) error { diff --git a/kite-service/cmd/plugin/deploy.go b/kite-service/cmd/plugin/deploy.go index a5eed8d..2335683 100644 --- a/kite-service/cmd/plugin/deploy.go +++ b/kite-service/cmd/plugin/deploy.go @@ -34,7 +34,7 @@ func deployCMD() *cli.Command { &cli.StringFlag{ Name: "server", Usage: "The Kite server to deploy to", - Value: "http://localhost:8080", + Value: "https://api.kite.onl", }, }, Action: func(c *cli.Context) error { diff --git a/kite-service/internal/api/api.go b/kite-service/internal/api/api.go index 07cc939..ac7b610 100644 --- a/kite-service/internal/api/api.go +++ b/kite-service/internal/api/api.go @@ -75,6 +75,7 @@ func (api *API) RegisterHandlers(engine *engine.Engine, pg *postgres.Client, acc v1Group := api.app.Group("/v1") authHandler := auth.New(sessionManager, pg, cfg) + v1Group.Get("/auth/invite", authHandler.HandleAuthInviteRedirect) v1Group.Get("/auth/redirect", authHandler.HandleAuthRedirect) v1Group.Get("/auth/callback", authHandler.HandleAuthCallback) v1Group.Get("/auth/logout", authHandler.HandleAuthLogout) diff --git a/kite-service/internal/api/handler/auth/handler.go b/kite-service/internal/api/handler/auth/handler.go index a6acb94..8ce1275 100644 --- a/kite-service/internal/api/handler/auth/handler.go +++ b/kite-service/internal/api/handler/auth/handler.go @@ -49,6 +49,17 @@ func New(sessionManager *session.SessionManager, userStore store.UserStore, cfg } } +func (h *AuthHandler) HandleAuthInviteRedirect(c *fiber.Ctx) error { + oauth2Config := *h.oauth2Config + oauth2Config.Scopes = append(oauth2Config.Scopes, discord.ScopeBot, discord.ScopeApplicationsCommands) + + state := setOauthStateCookie(c) + url := oauth2Config.AuthCodeURL(state) + // TODO: add permissions? + + return c.Redirect(url, http.StatusTemporaryRedirect) +} + func (h *AuthHandler) HandleAuthRedirect(c *fiber.Ctx) error { state := setOauthStateCookie(c) return c.Redirect(h.oauth2Config.AuthCodeURL(state), http.StatusTemporaryRedirect) @@ -74,7 +85,7 @@ func (h *AuthHandler) HandleAuthCallback(c *fiber.Ctx) error { return err } - return c.Redirect(h.cfg.App.AuthCallbackURL(), http.StatusTemporaryRedirect) + return c.Redirect(h.cfg.App.AuthCallbackURL()+"/app", http.StatusTemporaryRedirect) } func (h *AuthHandler) HandleAuthLogout(c *fiber.Ctx) error { diff --git a/kite-web/public/illustrations/wip.svg b/kite-web/public/illustrations/wip.svg index f1eb361..4812583 100644 --- a/kite-web/public/illustrations/wip.svg +++ b/kite-web/public/illustrations/wip.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/kite-web/src/pages/app/index.tsx b/kite-web/src/pages/app/index.tsx index 47dfc52..9b63250 100644 --- a/kite-web/src/pages/app/index.tsx +++ b/kite-web/src/pages/app/index.tsx @@ -1,7 +1,9 @@ import AppLayout from "@/components/app/AppLayout"; +import { getApiUrl } from "@/lib/api/client"; import { useGuildsQuery } from "@/lib/api/queries"; import { guildIconUrl } from "@/lib/discord/cdn"; import { guildNameAbbreviation } from "@/lib/discord/util"; +import { PlusCircleIcon } from "@heroicons/react/24/outline"; import Link from "next/link"; export default function GuildsPage() { @@ -48,6 +50,15 @@ export default function GuildsPage() { ))} + + +
+ Add to server +
+