Skip to content

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

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.

</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.

3 participants