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

Add route to connect with GitHub #788

Closed
3 tasks
begedin opened this issue Apr 24, 2017 · 0 comments
Closed
3 tasks

Add route to connect with GitHub #788

begedin opened this issue Apr 24, 2017 · 0 comments

Comments

@begedin
Copy link
Contributor

begedin commented Apr 24, 2017

Problem

The client will use the web application flow to connect with github. This provides the client with a code parameter, which it posts to the server.

We should add a POST /github_connect route and an action in the UserController which receives the code, calls a function to handle the API side of the flow, then signs in (to refresh) and renders the current user.

The module which gets called, if not yet implemented as part of another issue, can be temporarily defined under /lib/codecorps/github.ex. If not yet implemented, the function should be temporarily written as:

defmodule CodeCorps.GitHub do
  @doc """ 
  Temporary function until the actual behavior is implemented. 
  """
  def connect(user, _code), do: user
end

The github connect action requires authentication.

It calls Guardian.Plug.current_resource to retrieve the current user, then sends it, alongside the code parameter into the CodeCorps.GitHub.connect function. It receives back an {:ok, user} which can just be sent outwards, to be handled by ja_resource.

Subtasks

  • Add the POST /github_connect route
  • Add the UserController.github_connect/2 action. It
  • Add a user controller test for this action.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants