From 1299b3baf16dab7ddcc440238e213bad10fce06e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 2 May 2022 14:25:42 +0200 Subject: [PATCH] CAS Auth Fixes Signed-off-by: Thomas Citharel --- js/src/utils/auth.ts | 1 + lib/web/controllers/auth_controller.ex | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/js/src/utils/auth.ts b/js/src/utils/auth.ts index 534456782..e34db00c6 100644 --- a/js/src/utils/auth.ts +++ b/js/src/utils/auth.ts @@ -140,4 +140,5 @@ export const SELECTED_PROVIDERS: { [key: string]: string } = { google: "Google", keycloak: "Keycloak", ldap: "LDAP", + cas: "CAS", }; diff --git a/lib/web/controllers/auth_controller.ex b/lib/web/controllers/auth_controller.ex index f1ba410e8..014a112b7 100644 --- a/lib/web/controllers/auth_controller.ex +++ b/lib/web/controllers/auth_controller.ex @@ -4,6 +4,7 @@ defmodule Mobilizon.Web.AuthController do alias Mobilizon.Service.Auth.Authenticator alias Mobilizon.Users alias Mobilizon.Users.User + import Mobilizon.Service.Guards, only: [is_valid_string: 1] require Logger plug(:put_layout, false) @@ -106,7 +107,11 @@ defmodule Mobilizon.Web.AuthController do defp email_from_ueberauth(%Ueberauth.Auth{ extra: %Ueberauth.Auth.Extra{raw_info: %{user: %{"email" => email}}} }) - when not is_nil(email) and email != "", + when is_valid_string(email), + do: email + + defp email_from_ueberauth(%Ueberauth.Auth{info: %Ueberauth.Auth.Info{email: email}}) + when is_valid_string(email), do: email defp email_from_ueberauth(_), do: nil