Use token exchange method.
authorRoger Braun <roger@rogerbraun.net>
Sat, 9 Sep 2017 10:10:46 +0000 (12:10 +0200)
committerRoger Braun <roger@rogerbraun.net>
Sat, 9 Sep 2017 10:10:46 +0000 (12:10 +0200)
lib/pleroma/web/oauth/oauth_controller.ex

index a6a411573ce37f53dc92517efa117d998f4c05c5..579d6b3f4960495c46cc39f2d27715dba0c70da5 100644 (file)
@@ -25,12 +25,12 @@ defmodule Pleroma.Web.OAuth.OAuthController do
     end
   end
 
-  # TODO CRITICAL
-  # - Check validity of auth token
+  # TODO
+  # - proper scope handling
   def token_exchange(conn, %{"grant_type" => "authorization_code"} = params) do
     with %App{} = app <- Repo.get_by(App, client_id: params["client_id"], client_secret: params["client_secret"]),
          %Authorization{} = auth <- Repo.get_by(Authorization, token: params["code"], app_id: app.id),
-         {:ok, token} <- Token.create_token(app, Repo.get(User, auth.user_id)) do
+         {:ok, token} <- Token.exchange_token(app, auth) do
       response = %{
         token_type: "Bearer",
         access_token: token.token,