diff --git a/backend/users/api/IsExternalAuthAvailable.go b/backend/users/api/IsExternalAuthAvailable.go
new file mode 100644
index 0000000..8727ff1
--- /dev/null
+++ b/backend/users/api/IsExternalAuthAvailable.go
@@ -0,0 +1,16 @@
+package api
+
+import (
+ "net/http"
+ "ylem_users/config"
+)
+
+func IsExternalAuthAvailable(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+
+ if config.Cfg().Google.ClientId != "" {
+ w.WriteHeader(http.StatusOK)
+ } else {
+ w.WriteHeader(http.StatusNotFound)
+ }
+}
diff --git a/backend/users/services/server/server.go b/backend/users/services/server/server.go
index 28e9e69..884bfc6 100644
--- a/backend/users/services/server/server.go
+++ b/backend/users/services/server/server.go
@@ -43,6 +43,7 @@ func (s *Server) Run(ctx context.Context) error {
rtr.Handle("/email/{key}/confirm", http.HandlerFunc(api.ConfirmEmail)).Methods(http.MethodPost)
rtr.Handle("/auth/{provider}", http.HandlerFunc(api.ExternalAuth)).Methods(http.MethodGet)
+ rtr.Handle("/auth/{provider}/available", http.HandlerFunc(api.IsExternalAuthAvailable)).Methods(http.MethodGet)
rtr.Handle("/auth/{provider}/callback", authMiddleware.IsNotAuthCheck(http.HandlerFunc(authMiddleware.ExternalAuthCallback))).Methods(http.MethodPost)
// The following endpoints are for the internal use only and should be
diff --git a/ui/src/components/login.component.js b/ui/src/components/login.component.js
index 2454eda..929e36e 100644
--- a/ui/src/components/login.component.js
+++ b/ui/src/components/login.component.js
@@ -30,17 +30,21 @@ class Login extends Component {
this.onChangeEmail = this.onChangeEmail.bind(this);
this.onChangePassword = this.onChangePassword.bind(this);
this.handleSignInWithGoogle = this.handleSignInWithGoogle.bind(this);
+ this.handleGetSignInWithGoogleAvailability = this.handleGetSignInWithGoogleAvailability.bind(this);
this.state = {
email: "",
password: "",
loading: false,
+ isGoogleAuthAvailable: null,
isDarkThemeEnabled: localStorage.getItem('darkTheme') !== "false",
};
}
componentDidMount() {
- document.title = 'Login'
+ document.title = 'Login';
+
+ this.handleGetSignInWithGoogleAvailability();
};
onChangeEmail(e) {
@@ -96,10 +100,26 @@ class Login extends Component {
});
}
+ handleGetSignInWithGoogleAvailability() {
+ let isAvailable = AuthService.getSignInWithGoogleAvailability()
+
+ Promise.resolve(isAvailable)
+ .then(isAvailable => {
+ this.setState({
+ isGoogleAuthAvailable: true,
+ });
+ })
+ .catch(() => {
+ this.setState({
+ isGoogleAuthAvailable: false,
+ });
+ });
+ }
+
render() {
const { isLoggedIn, user, message } = this.props;
- const { isDarkThemeEnabled } = this.state;
+ const { isDarkThemeEnabled, isGoogleAuthAvailable } = this.state;
if (!validatePermissions(isLoggedIn, user, PERMISSION_LOGGED_OUT)) {
return