forked from eightants/reddium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Reddit OAuth2 settings to be configured from env vars (#6)
Create a LoginButton component and expose OAuth2 env vars for config
- Loading branch information
Showing
6 changed files
with
54 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useConfig } from '../../functions/useConfig'; | ||
import Link from 'next/link'; | ||
|
||
const LoginButton = () => { | ||
const { config } = useConfig(); | ||
const { REDDIUM_CLIENT_ID, REDDIUM_DISABLE_LOGIN, REDDIUM_DOMAIN } = config; | ||
const REDIRECT_URI = `${REDDIUM_DOMAIN}/login`; | ||
|
||
if (REDDIUM_DISABLE_LOGIN) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Link href={`https://www.reddit.com/api/v1/authorize.compact?client_id=${REDDIUM_CLIENT_ID}&response_type=code&state=testing&redirect_uri=${REDIRECT_URI}&duration=temporary&scope=${encodeURIComponent( | ||
"read vote save identity subscribe" | ||
)}`}> | ||
<button className="my-4 ml-4 p-1 px-3 text-sm cursor-pointer max-w-full btn-black text-white outline-1px rounded"> | ||
Login | ||
</button> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default LoginButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters