From 046c210e91fc03e1c670a0a28ea4849968c77056 Mon Sep 17 00:00:00 2001 From: hellekin Date: Mon, 5 Oct 2020 22:10:26 +0200 Subject: Add Authentication logic The ApplicationController provides a `current_user` method (and helper) to access the authenticated user (if any). The WelcomeController provides minimal logic to authenticate against DiscourseSSO. Current state is that one can login and logout. Views need a lot of work. --- app/views/welcome/authenticate.html.erb | 15 +++++++++++++++ app/views/welcome/dashboard.html.erb | 5 +++++ app/views/welcome/index.html.erb | 8 ++++++++ 3 files changed, 28 insertions(+) create mode 100644 app/views/welcome/authenticate.html.erb create mode 100644 app/views/welcome/dashboard.html.erb create mode 100644 app/views/welcome/index.html.erb (limited to 'app/views/welcome') diff --git a/app/views/welcome/authenticate.html.erb b/app/views/welcome/authenticate.html.erb new file mode 100644 index 0000000..548101b --- /dev/null +++ b/app/views/welcome/authenticate.html.erb @@ -0,0 +1,15 @@ +

Authentication#sso_callback

+ +

Welcome <%= @current_user&.name %>!

+ +

Your Agents: +

+

+ +<%= p @current_user %> +<%= p @sso.user_info %> +<%= p session %> diff --git a/app/views/welcome/dashboard.html.erb b/app/views/welcome/dashboard.html.erb new file mode 100644 index 0000000..81264e2 --- /dev/null +++ b/app/views/welcome/dashboard.html.erb @@ -0,0 +1,5 @@ +

Welcome <%= h current_user.name %>!

+ +

Current Agent: <%= current_user&.agencies&.first&.agent&.name %>

+ +

Cool, what can we do now?

diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb new file mode 100644 index 0000000..a1fa276 --- /dev/null +++ b/app/views/welcome/index.html.erb @@ -0,0 +1,8 @@ +

Bienvenue à l'atelier carto d'IN COMMON

+ +<% if current_user.present? %> +

Hi <%= h current_user.name %>, please <%= link_to 'proceed to your dashboard', url_for(action: 'dashboard') %>.

+

You may <%= link_to 'sign off', logout_url %>.

+<% else %> +

<%= link_to "S'identifier avec Talk.incommon.cc", '/authenticate' %>

+<% end %> -- cgit v1.2.3