Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
kahlstrm committed Jul 15, 2024
1 parent b5e10ef commit 9612333
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 151 deletions.
40 changes: 20 additions & 20 deletions packages/payload-plugin-oauth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ yarn add payload-plugin-oauth@^1

```js
// payload.config.ts
import path from 'path'
import path from "path";

import { webpackBundler } from '@payloadcms/bundler-webpack'
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { slateEditor } from '@payloadcms/richtext-slate'
import axios from 'axios'
import { oAuthPlugin } from 'payload-plugin-oauth'
import { buildConfig } from 'payload/config'
import Users from './collections/Users'
import { webpackBundler } from "@payloadcms/bundler-webpack";
import { mongooseAdapter } from "@payloadcms/db-mongodb";
import { slateEditor } from "@payloadcms/richtext-slate";
import axios from "axios";
import { oAuthPlugin } from "payload-plugin-oauth";
import { buildConfig } from "payload/config";
import Users from "./collections/Users";

export default buildConfig({
admin: {
Expand All @@ -56,47 +56,47 @@ export default buildConfig({
editor: slateEditor({}),
collections: [Users],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
outputFile: path.resolve(__dirname, "payload-types.ts"),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
schemaOutputFile: path.resolve(__dirname, "generated-schema.graphql"),
},
plugins: [
payloadCloud(),
oAuthPlugin({
buttonLabel: 'Sign in with oAuth',
buttonLabel: "Sign in with oAuth",
databaseUri: process.env.DATABASE_URI,
clientID: process.env.OAUTH_CLIENT_ID,
clientSecret: process.env.OAUTH_CLIENT_SECRET,
authorizationURL: process.env.OAUTH_AUTH_ENDPOINT,
tokenURL: process.env.OAUTH_TOKEN_ENDPOINT,
authorizePath: '/oauth/authorize1',
callbackURL: process.env.ORIGIN + '/oauth/callback1',
authorizePath: "/oauth/authorize1",
callbackURL: process.env.ORIGIN + "/oauth/callback1",
async userinfo(accessToken) {
const { data: user } = await axios.get(
process.env.OAUTH_USERINFO_ENDPOINT,
{ headers: { Authorization: `Bearer ${accessToken}` } }
)
{ headers: { Authorization: `Bearer ${accessToken}` } },
);
return {
sub: user.ID,
username: user.preferred_username,
}
};
},
}),
// Another oAuth provider
oAuthPlugin({
buttonLabel: 'Sign in with Alternative',
buttonLabel: "Sign in with Alternative",
// These paths must be unique per provider
authorizePath: '/oauth/authorize2',
callbackURL: process.env.ORIGIN + '/oauth/callback2',
authorizePath: "/oauth/authorize2",
callbackURL: process.env.ORIGIN + "/oauth/callback2",

...rest,
}),
],
db: mongooseAdapter({
url: process.env.DATABASE_URI,
}),
})
});
```

## Changelog
Expand Down
8 changes: 4 additions & 4 deletions packages/payload-plugin-oauth/src/OAuthButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Button from 'payload/dist/admin/components/elements/Button'
import React from 'react'
import { ButtonProps } from './types'
import Button from "payload/dist/admin/components/elements/Button";
import React from "react";
import { ButtonProps } from "./types";

export default function OAuthButton(props: ButtonProps) {
return (
Expand All @@ -9,5 +9,5 @@ export default function OAuthButton(props: ButtonProps) {
{props.buttonLabel}
</Button>
</div>
)
);
}
Loading

0 comments on commit 9612333

Please sign in to comment.