Commit 22c96d1

mo <mo.khan@gmail.com>
2018-09-09 17:03:42
use jbuilder to render response.
1 parent 271e0e6
Changed files (2)
app/controllers/oauths_controller.rb
@@ -22,11 +22,6 @@ class OauthsController < ApplicationController
     response.headers['Cache-Control'] = 'no-store'
     response.headers['Pragma'] = 'no-cache'
     Authorization.find_by!(code: params[:code]).revoke!
-    render json: {
-      access_token: SecureRandom.hex(20),
-      token_type: 'access',
-      expires_in: 1.hour.to_i,
-      refresh_token: SecureRandom.hex(20)
-    }, status: :ok
+    render formats: :json
   end
 end
app/views/oauths/token.json.jbuilder
@@ -0,0 +1,4 @@
+json.access_token SecureRandom.hex(20)
+json.token_type 'access'
+json.expires_in 1.hour.to_i
+json.refresh_token SecureRandom.hex(20)