From 8b7f1331eea885a346be63a308613ee4373c3aea Mon Sep 17 00:00:00 2001 From: Dmitry Verkhoturov Date: Wed, 4 Jan 2023 10:29:46 +0400 Subject: [PATCH] add Apple auth provider frontend support With distinct logos for light and dark theme from https://devimages-cdn.apple.com/design/resources/download/Logo-Sign-in-with-Apple.dmg --- .../apps/remark42/app/assets/social/apple-dark.svg | 10 ++++++++++ .../apps/remark42/app/assets/social/apple-light.svg | 10 ++++++++++ frontend/apps/remark42/app/common/types.ts | 1 + .../apps/remark42/app/components/auth/auth.spec.tsx | 1 + .../app/components/auth/components/oauth.consts.ts | 7 +++++++ frontend/packages/api/clients/index.ts | 1 + site/src/docs/configuration/authorization/index.md | 2 +- 7 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 frontend/apps/remark42/app/assets/social/apple-dark.svg create mode 100755 frontend/apps/remark42/app/assets/social/apple-light.svg diff --git a/frontend/apps/remark42/app/assets/social/apple-dark.svg b/frontend/apps/remark42/app/assets/social/apple-dark.svg new file mode 100755 index 00000000..389c544f --- /dev/null +++ b/frontend/apps/remark42/app/assets/social/apple-dark.svg @@ -0,0 +1,10 @@ + + + + White Logo Square + Created with Sketch. + + + + + diff --git a/frontend/apps/remark42/app/assets/social/apple-light.svg b/frontend/apps/remark42/app/assets/social/apple-light.svg new file mode 100755 index 00000000..d3b2556f --- /dev/null +++ b/frontend/apps/remark42/app/assets/social/apple-light.svg @@ -0,0 +1,10 @@ + + + + Black Logo Square + Created with Sketch. + + + + + diff --git a/frontend/apps/remark42/app/common/types.ts b/frontend/apps/remark42/app/common/types.ts index 1fe9177d..2b7b0ee0 100644 --- a/frontend/apps/remark42/app/common/types.ts +++ b/frontend/apps/remark42/app/common/types.ts @@ -97,6 +97,7 @@ export interface Tree { } export type OAuthProvider = + | 'apple' | 'facebook' | 'twitter' | 'google' diff --git a/frontend/apps/remark42/app/components/auth/auth.spec.tsx b/frontend/apps/remark42/app/components/auth/auth.spec.tsx index 726ce4fe..9df6e605 100644 --- a/frontend/apps/remark42/app/components/auth/auth.spec.tsx +++ b/frontend/apps/remark42/app/components/auth/auth.spec.tsx @@ -74,6 +74,7 @@ describe('', () => { [['facebook', 'google', 'microsoft']], [['facebook', 'google', 'microsoft', 'yandex']], [['facebook', 'google', 'microsoft', 'yandex', 'twitter']], + [['facebook', 'google', 'microsoft', 'yandex', 'twitter', 'apple']], ] as [OAuthProvider[]][])('should renders with %j providers', async (providers) => { StaticStore.config.auth_providers = providers; diff --git a/frontend/apps/remark42/app/components/auth/components/oauth.consts.ts b/frontend/apps/remark42/app/components/auth/components/oauth.consts.ts index afa7ab97..61e217a1 100644 --- a/frontend/apps/remark42/app/components/auth/components/oauth.consts.ts +++ b/frontend/apps/remark42/app/components/auth/components/oauth.consts.ts @@ -1,4 +1,11 @@ export const OAUTH_DATA = { + apple: { + name: 'Apple', + icons: { + light: require('assets/social/apple-light.svg').default as string, + dark: require('assets/social/apple-dark.svg').default as string, + }, + }, facebook: require('assets/social/facebook.svg').default as string, twitter: require('assets/social/twitter.svg').default as string, patreon: require('assets/social/patreon.svg').default as string, diff --git a/frontend/packages/api/clients/index.ts b/frontend/packages/api/clients/index.ts index 53647888..3b648e31 100644 --- a/frontend/packages/api/clients/index.ts +++ b/frontend/packages/api/clients/index.ts @@ -17,6 +17,7 @@ export interface User { } export type OAuthProvider = + | 'apple' | 'facebook' | 'twitter' | 'google' diff --git a/site/src/docs/configuration/authorization/index.md b/site/src/docs/configuration/authorization/index.md index 32bc1a55..8978c3f1 100644 --- a/site/src/docs/configuration/authorization/index.md +++ b/site/src/docs/configuration/authorization/index.md @@ -6,7 +6,7 @@ title: Authorization Authentication handled by external providers. You should set up OAuth2 for at least one of them to allow users to make comments. It is not mandatory to have all of them, but one should be correctly configured. -### Apple (not implemented yet) +### Apple 1. Log in [to the developer account](https://developer.apple.com/account). 1. If you don't have an App ID yet, [create one](https://developer.apple.com/account/resources/identifiers/add/bundleId). Later on, you'll need **TeamID**, which is an "App ID Prefix" value.