mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-21 17:26:29 -05:00
renamed via-oauth2 to via-one-click
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
c5bc4c4dcd
commit
58f3bb4d3b
2 changed files with 27 additions and 27 deletions
|
@ -2,7 +2,7 @@ import React from "react";
|
||||||
import {IconProp} from "@fortawesome/fontawesome-svg-core";
|
import {IconProp} from "@fortawesome/fontawesome-svg-core";
|
||||||
import {IconButton} from "./icon-button/icon-button";
|
import {IconButton} from "./icon-button/icon-button";
|
||||||
|
|
||||||
export enum OAuth2Type {
|
export enum OneClickType {
|
||||||
'DROPBOX'="dropbox",
|
'DROPBOX'="dropbox",
|
||||||
'FACEBOOK'="facebook",
|
'FACEBOOK'="facebook",
|
||||||
'GITHUB'="github",
|
'GITHUB'="github",
|
||||||
|
@ -13,7 +13,7 @@ export enum OAuth2Type {
|
||||||
'TWITTER'="twitter"
|
'TWITTER'="twitter"
|
||||||
}
|
}
|
||||||
|
|
||||||
type OAuth2Map = (oauth2type: OAuth2Type) => {
|
type OneClick2Map = (oneClickType: OneClickType) => {
|
||||||
name: string,
|
name: string,
|
||||||
icon: IconProp,
|
icon: IconProp,
|
||||||
className: string,
|
className: string,
|
||||||
|
@ -24,58 +24,58 @@ const buildBackendAuthUrl = (backendName: string) => {
|
||||||
return `https://localhost:3000/auth/${backendName}`
|
return `https://localhost:3000/auth/${backendName}`
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMetadata: OAuth2Map = (oauth2type: OAuth2Type) => {
|
const getMetadata: OneClick2Map = (oneClickType: OneClickType) => {
|
||||||
switch (oauth2type) {
|
switch (oneClickType) {
|
||||||
case OAuth2Type.DROPBOX:
|
case OneClickType.DROPBOX:
|
||||||
return {
|
return {
|
||||||
name: "Dropbox",
|
name: "Dropbox",
|
||||||
icon: ["fab", "dropbox"],
|
icon: ["fab", "dropbox"],
|
||||||
className: "btn-social-dropbox",
|
className: "btn-social-dropbox",
|
||||||
url: buildBackendAuthUrl("dropbox")
|
url: buildBackendAuthUrl("dropbox")
|
||||||
}
|
}
|
||||||
case OAuth2Type.FACEBOOK:
|
case OneClickType.FACEBOOK:
|
||||||
return {
|
return {
|
||||||
name: "Facebook",
|
name: "Facebook",
|
||||||
icon: ["fab", "facebook"],
|
icon: ["fab", "facebook"],
|
||||||
className: "btn-social-facebook",
|
className: "btn-social-facebook",
|
||||||
url: buildBackendAuthUrl("facebook")
|
url: buildBackendAuthUrl("facebook")
|
||||||
}
|
}
|
||||||
case OAuth2Type.GITHUB:
|
case OneClickType.GITHUB:
|
||||||
return {
|
return {
|
||||||
name: "GitHub",
|
name: "GitHub",
|
||||||
icon: ["fab", "github"],
|
icon: ["fab", "github"],
|
||||||
className: "btn-social-github",
|
className: "btn-social-github",
|
||||||
url: buildBackendAuthUrl("github")
|
url: buildBackendAuthUrl("github")
|
||||||
}
|
}
|
||||||
case OAuth2Type.GITLAB:
|
case OneClickType.GITLAB:
|
||||||
return {
|
return {
|
||||||
name: "GitLab",
|
name: "GitLab",
|
||||||
icon: ["fab", "gitlab"],
|
icon: ["fab", "gitlab"],
|
||||||
className: "btn-social-gitlab",
|
className: "btn-social-gitlab",
|
||||||
url: buildBackendAuthUrl("gitlab")
|
url: buildBackendAuthUrl("gitlab")
|
||||||
}
|
}
|
||||||
case OAuth2Type.GOOGLE:
|
case OneClickType.GOOGLE:
|
||||||
return {
|
return {
|
||||||
name: "Google",
|
name: "Google",
|
||||||
icon: ["fab", "google"],
|
icon: ["fab", "google"],
|
||||||
className: "btn-social-google",
|
className: "btn-social-google",
|
||||||
url: buildBackendAuthUrl("google")
|
url: buildBackendAuthUrl("google")
|
||||||
}
|
}
|
||||||
case OAuth2Type.OAUTH2:
|
case OneClickType.OAUTH2:
|
||||||
return {
|
return {
|
||||||
name: "OAuth2",
|
name: "OAuth2",
|
||||||
icon: "share",
|
icon: "share",
|
||||||
className: "btn-primary",
|
className: "btn-primary",
|
||||||
url: buildBackendAuthUrl("oauth2")
|
url: buildBackendAuthUrl("oauth2")
|
||||||
}
|
}
|
||||||
case OAuth2Type.SAML:
|
case OneClickType.SAML:
|
||||||
return {
|
return {
|
||||||
name: "SAML",
|
name: "SAML",
|
||||||
icon: "users",
|
icon: "users",
|
||||||
className: "btn-success",
|
className: "btn-success",
|
||||||
url: buildBackendAuthUrl("saml")
|
url: buildBackendAuthUrl("saml")
|
||||||
}
|
}
|
||||||
case OAuth2Type.TWITTER:
|
case OneClickType.TWITTER:
|
||||||
return {
|
return {
|
||||||
name: "Twitter",
|
name: "Twitter",
|
||||||
icon: ["fab", "twitter"],
|
icon: ["fab", "twitter"],
|
||||||
|
@ -92,13 +92,13 @@ const getMetadata: OAuth2Map = (oauth2type: OAuth2Type) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ViaOAuth2Props {
|
export interface ViaOneClickProps {
|
||||||
oauth2Type: OAuth2Type;
|
oneClickType: OneClickType;
|
||||||
optionalName?: string;
|
optionalName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ViaOAuth2: React.FC<ViaOAuth2Props> = ({oauth2Type, optionalName}) => {
|
const ViaOneClick: React.FC<ViaOneClickProps> = ({oneClickType, optionalName}) => {
|
||||||
const {name, icon, className, url} = getMetadata(oauth2Type);
|
const {name, icon, className, url} = getMetadata(oneClickType);
|
||||||
const text = !!optionalName ? optionalName : name;
|
const text = !!optionalName ? optionalName : name;
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
|
@ -112,4 +112,4 @@ const ViaOAuth2: React.FC<ViaOAuth2Props> = ({oauth2Type, optionalName}) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export {ViaOAuth2}
|
export {ViaOneClick}
|
|
@ -2,7 +2,7 @@ import React from "react"
|
||||||
import {Col, Jumbotron, Row} from "react-bootstrap"
|
import {Col, Jumbotron, Row} from "react-bootstrap"
|
||||||
import {Trans, useTranslation} from "react-i18next";
|
import {Trans, useTranslation} from "react-i18next";
|
||||||
import {ViaEMail} from "./auth/via-email";
|
import {ViaEMail} from "./auth/via-email";
|
||||||
import {OAuth2Type, ViaOAuth2} from "./auth/via-oauth2";
|
import {OneClickType, ViaOneClick} from "./auth/via-one-click";
|
||||||
import {ViaLdap} from "./auth/via-ldap";
|
import {ViaLdap} from "./auth/via-ldap";
|
||||||
import {useSelector} from "react-redux";
|
import {useSelector} from "react-redux";
|
||||||
import {ApplicationState} from "../../../../redux";
|
import {ApplicationState} from "../../../../redux";
|
||||||
|
@ -13,13 +13,13 @@ const Login: React.FC = () => {
|
||||||
const customAuthNames = useSelector((state: ApplicationState) => state.backendConfig.customAuthNames);
|
const customAuthNames = useSelector((state: ApplicationState) => state.backendConfig.customAuthNames);
|
||||||
const emailForm = authProviders.email ? <ViaEMail/> : null
|
const emailForm = authProviders.email ? <ViaEMail/> : null
|
||||||
const ldapForm = authProviders.ldap ? <ViaLdap/> : null
|
const ldapForm = authProviders.ldap ? <ViaLdap/> : null
|
||||||
const emailLdapSeperator = authProviders.email && authProviders.ldap ? <hr className="w-100 bg-white"/> : null
|
const emailLdapSeparator = authProviders.email && authProviders.ldap ? <hr className="w-100 bg-white"/> : null
|
||||||
|
|
||||||
const oauth2CustomName: (type: OAuth2Type) => string | undefined = (type) => {
|
const oneClickCustomName: (type: OneClickType) => string | undefined = (type) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OAuth2Type.SAML:
|
case OneClickType.SAML:
|
||||||
return customAuthNames.saml;
|
return customAuthNames.saml;
|
||||||
case OAuth2Type.OAUTH2:
|
case OneClickType.OAUTH2:
|
||||||
return customAuthNames.oauth2;
|
return customAuthNames.oauth2;
|
||||||
default:
|
default:
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -34,7 +34,7 @@ const Login: React.FC = () => {
|
||||||
authProviders.email || authProviders.ldap ?
|
authProviders.email || authProviders.ldap ?
|
||||||
<Col xs={12} sm={10} lg={3}>
|
<Col xs={12} sm={10} lg={3}>
|
||||||
{emailForm}
|
{emailForm}
|
||||||
{emailLdapSeperator}
|
{emailLdapSeparator}
|
||||||
{ldapForm}
|
{ldapForm}
|
||||||
<hr className="w-100 d-lg-none d-block bg-white"/>
|
<hr className="w-100 d-lg-none d-block bg-white"/>
|
||||||
</Col>
|
</Col>
|
||||||
|
@ -46,7 +46,7 @@ const Login: React.FC = () => {
|
||||||
</h5>
|
</h5>
|
||||||
<div className={"d-flex flex-wrap one-click-login justify-content-center"}>
|
<div className={"d-flex flex-wrap one-click-login justify-content-center"}>
|
||||||
{
|
{
|
||||||
Object.values(OAuth2Type)
|
Object.values(OneClickType)
|
||||||
.filter((value) => authProviders[value])
|
.filter((value) => authProviders[value])
|
||||||
.map((value) => {
|
.map((value) => {
|
||||||
return (
|
return (
|
||||||
|
@ -56,9 +56,9 @@ const Login: React.FC = () => {
|
||||||
className="p-2 d-flex flex-column"
|
className="p-2 d-flex flex-column"
|
||||||
key={value}
|
key={value}
|
||||||
>
|
>
|
||||||
<ViaOAuth2
|
<ViaOneClick
|
||||||
oauth2Type={value}
|
oneClickType={value}
|
||||||
optionalName={oauth2CustomName(value)}
|
optionalName={oneClickCustomName(value)}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue