-
Notifications
You must be signed in to change notification settings - Fork 135
Added ability to opt back in #59
base: master
Are you sure you want to change the base?
Conversation
How about explicit opt-in via starring the repo? https://github.com/resume/resume.github.com/blob/master/js/githubresume.js#L112 |
@dfm: Does this look good to merge? |
@dfm: Ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've switched to using random.choices which can generate the list of characters in one call rather than iterating with a list comprehension.
I used an f-string to format the auth_url
Instead of just urllib.urlencode, I've used urllib.parse.urlencode. This is the more modern way of importing it, especially if you're using Python 3.
I used a more conventional way to define the dictionary params.
def opt_in_login(username): | ||
state = "".join([random.choice(string.ascii_uppercase + string.digits) | ||
for x in range(24)]) | ||
flask.session["state"] = state | ||
params = dict( | ||
client_id=flask.current_app.config["GITHUB_ID"], | ||
redirect_uri=flask.url_for(".opt_in_callback", username=username, | ||
_external=True), | ||
state=state, | ||
) | ||
return flask.redirect("https://github.com/login/oauth/authorize?{0}" | ||
.format(urllib.urlencode(params))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def opt_in_login(username): | |
state = "".join([random.choice(string.ascii_uppercase + string.digits) | |
for x in range(24)]) | |
flask.session["state"] = state | |
params = dict( | |
client_id=flask.current_app.config["GITHUB_ID"], | |
redirect_uri=flask.url_for(".opt_in_callback", username=username, | |
_external=True), | |
state=state, | |
) | |
return flask.redirect("https://github.com/login/oauth/authorize?{0}" | |
.format(urllib.urlencode(params))) | |
def opt_in_login(username): | |
state = ''.join(random.choices(string.ascii_uppercase + string.digits, k=24)) | |
flask.session["state"] = state | |
params = { | |
'client_id': flask.current_app.config["GITHUB_ID"], | |
'redirect_uri': flask.url_for('.opt_in_callback', username=username, _external=True), | |
'state': state, | |
} | |
auth_url = f"https://github.com/login/oauth/authorize?{urllib.parse.urlencode(params)}" | |
return flask.redirect(auth_url) |
No description provided.