Authenticating using Clearance or DIY - doorkeeper-gem/doorkeeper GitHub Wiki
If you are not using devise/warden - and using clearance/DIY, you won't have access to a current_user
helper. You'll need to access the authenticated user through the session (or the env
variable if you're using Clearance >= 0.13.0
).
The follow example uses the env
variable to get the authenticated user.
config/initializers/doorkeeper.rb
resource_owner_authenticator do
@user = env[:clearance].current_user
unless @user
session[:return_to] = request.fullpath
redirect_to(sign_in_url)
end
@user
end
app/views/layouts/doorkeeper.html.erb
<html>
...
<div id="current_user"><%= @user.username %></div>
...
</html>