Skip to content

Commit

Permalink
add a store page for debug purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
mose committed Jan 6, 2016
1 parent 9bb706d commit 4c86805
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/views/home.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="meat text">
Welcome to hieraviz<br>
<%= session['access_token'] %>
<%= session['access_token'] %><br>
<pre><%= settings.store.get session['access_token'] if session['access_token'] %></pre>
</div>
5 changes: 5 additions & 0 deletions app/views/store.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="meat text">
<h1>Store</h1>
<%= session['access_token'] %><br>
<pre><%= settings.store.dump %></pre>
</div>
6 changes: 6 additions & 0 deletions app/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Web < Common
set :session_secret, settings.configdata['session_seed']
set :public_folder, Proc.new { File.join(root, "public") }
set :views_folder, Proc.new { File.join(root, "views") }
set :store, Hieraviz::Store.new
set :erb, layout: :_layout
enable :sessions
end
Expand Down Expand Up @@ -69,6 +70,7 @@ def check_authorization
get '/logged-in' do
access_token = settings.oauth.access_token(request, params[:code])
session[:access_token] = access_token.token
settings.store.set access_token.token, settings.oauth.user_info(access_token.token)
flash['info'] = "Successfully authenticated with the server"
redirect '/'
end
Expand Down Expand Up @@ -108,6 +110,10 @@ def check_authorization
erb :resources
end

get '/store' do
erb :store
end

not_found do
erb :not_found, layout: :_layout
end
Expand Down
4 changes: 4 additions & 0 deletions lib/hieraviz/auth_gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ def authorized?(token)
true
end

def user_info(token)
get_response('/api/v3/user', token)
end

end
end
4 changes: 4 additions & 0 deletions lib/hieraviz/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ def get(key)
@data[key.to_sym]
end

def dump
@data
end

end
end

0 comments on commit 4c86805

Please sign in to comment.