diff --git a/app/scenes/Login/OAuthAuthorize.tsx b/app/scenes/Login/OAuthAuthorize.tsx index 8cb06cfad2..1f35c31731 100644 --- a/app/scenes/Login/OAuthAuthorize.tsx +++ b/app/scenes/Login/OAuthAuthorize.tsx @@ -1,8 +1,14 @@ +import { MoreIcon } from "outline-icons"; import React from "react"; import { useTranslation } from "react-i18next"; +import styled from "styled-components"; +import Flex from "@shared/components/Flex"; +import { s } from "@shared/styles"; +import { Avatar, AvatarSize } from "~/components/Avatar"; import Button from "~/components/Button"; import ChangeLanguage from "~/components/ChangeLanguage"; -import TeamLogo from "~/components/TeamLogo"; +import Heading from "~/components/Heading"; +import Text from "~/components/Text"; import useCurrentTeam from "~/hooks/useCurrentTeam"; import useQuery from "~/hooks/useQuery"; import useRequest from "~/hooks/useRequest"; @@ -21,10 +27,12 @@ function Authorize() { const responseType = params.get("response_type"); const state = params.get("state"); const scope = params.get("scope"); - // const [scopes] = React.useState(() => scope?.split(" ") ?? []); - const { error, data, request } = useRequest(() => - client.post("/oauthClients.info", { clientId }) - ); + const [scopes] = React.useState(() => scope?.split(" ") ?? []); + const { + error, + data: response, + request, + } = useRequest(() => client.post("/oauthClients.info", { clientId })); React.useEffect(() => { if (clientId) { @@ -32,19 +40,50 @@ function Authorize() { } }, []); + const missingParams = [ + !clientId && "client_id", + !clientSecret && "client_secret", + !redirectUri && "redirect_uri", + !responseType && "response_type", + !state && "state", + !scope && "scope", + ].filter(Boolean); + + if (missingParams.length) { + return ( + + + + {t("Error")} + + {t("Required OAuth parameters are missing")} +
+              {missingParams.map((param) => (
+                <>
+                  {param}
+                  
+ + ))} +
+
+
+
+ ); + } + if (error) { return ( -

{t("Error")}

+ {t("Error")}

{t("Unable to load OAuth client")}

); } - if (!data) { + if (!response) { // TODO return null; } @@ -54,11 +93,29 @@ function Authorize() { - {team.name} -

{data.data.name}

-

{data.data.developerName}

-

{data.data.developerUrl}

-

{data.data.description}

+ + {" "} + {" "} + + + + {response.data.name} wants to access {team.name} + +

+ {scopes.map((item) => ( + <> + {item} +
+ + ))} +

-
@@ -83,4 +140,23 @@ function Authorize() { ); } +const Logo = styled(Avatar)` + border-radius: 8px; +`; + +const StyledHeading = styled(Heading).attrs({ + as: "h2", + centered: true, +})` + margin-top: 0; +`; + +const Pre = styled.pre` + background: ${s("backgroundSecondary")}; + padding: 16px; + border-radius: 4px; + font-size: 12px; + white-space: pre-wrap; +`; + export default Authorize; diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index ea9b9faab9..8652910797 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -118,6 +118,7 @@ "Log out": "Log out", "Mark notifications as read": "Mark notifications as read", "Archive all notifications": "Archive all notifications", + "New App": "New App", "Restore revision": "Restore revision", "Link copied": "Link copied", "Dark": "Dark", @@ -515,6 +516,7 @@ "Features": "Features", "Members": "Members", "Groups": "Groups", + "Applications": "Applications", "Shared Links": "Shared Links", "Import": "Import", "Self Hosted": "Self Hosted", @@ -820,6 +822,9 @@ "You signed in with {{ authProviderName }} last time.": "You signed in with {{ authProviderName }} last time.", "Or": "Or", "Already have an account? Go to <1>login.": "Already have an account? Go to <1>login.", + "Required OAuth parameters are missing": "Required OAuth parameters are missing", + "Unable to load OAuth client": "Unable to load OAuth client", + "Authorize": "Authorize", "Any collection": "Any collection", "All time": "All time", "Past day": "Past day", @@ -837,6 +842,7 @@ "No documents found for your search filters.": "No documents found for your search filters.", "API": "API", "API keys can be used to authenticate with the API and programatically control\n your workspace's data. For more details see the developer documentation.": "API keys can be used to authenticate with the API and programatically control\n your workspace's data. For more details see the developer documentation.", + "OAuth apps can be used to authenticate with the API and programatically control\n your workspace's data. For more details see the developer documentation.": "OAuth apps can be used to authenticate with the API and programatically control\n your workspace's data. For more details see the developer documentation.", "by {{ name }}": "by {{ name }}", "Last used": "Last used", "No expiry": "No expiry", @@ -908,6 +914,7 @@ "Drag and drop the zip file from Notion's HTML export option, or click to upload": "Drag and drop the zip file from Notion's HTML export option, or click to upload", "Last active": "Last active", "Guest": "Guest", + "Client secret copied to clipboard": "Client secret copied to clipboard", "Shared by": "Shared by", "Date shared": "Date shared", "Last accessed": "Last accessed",