Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jank oAuth implement #108

Open
wants to merge 6 commits into
base: staging
Choose a base branch
from
Open

jank oAuth implement #108

wants to merge 6 commits into from

Conversation

bz22
Copy link

@bz22 bz22 commented Jun 30, 2020

Implemented oAuth flow that connects with backend. Most github operations are performed in the backend to avoid third party interference. Have to refactor:

  1. parameter names because they're changed to be in compliance with user_schema
  2. add try catch block when requesting from github API and retrieving keys in dictionaries
  3. make front-end redirection page
  4. store github_id into the backend database as well
  5. refactor github_client and secret to some env or settings file

@vercel
Copy link

vercel bot commented Jun 30, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/bitproject/bit-next/dyw2tuk01
✅ Preview: https://bit-next-git-brandon3.bitproject.vercel.app

def register_extensions(app):
"""Register Flask extensions."""
bcrypt.init_app(app)
cache.init_app(app)
db.init_app(app)
migrate.init_app(app, db)
jwt.init_app(app)
app.config['GITHUB_CLIENT_ID'] = '98574e099fa640413899'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should put the client secret and client id in the .env file

#refactor and hide these

#NOTE: use try catch block later
payload = { 'client_id': "98574e099fa640413899",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace hard coded secrets with environment variables.

user.token = create_access_token(identity=user, fresh=True)
return user

# Flask Migrate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erase any code/comments that you no longer need

const code = new URLSearchParams(window.location.search).get("code");
if (code){
logging_in = (<p>Redirecting to home page...</p>);
React.useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import the useState function from react instead of React.useState. Makes the code more easy to read.

@@ -77,8 +106,13 @@ const LoginForm = () => {
</button>
</fieldset>
</form>
<a href="https://github.com/login/oauth/authorize?client_id=98574e099fa640413899&scope=user+repo"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again use environment variables instead of hard coded values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants