mirror of
https://github.com/wassname/talk.git
synced 2026-08-12 12:30:39 +08:00
[CORL-621] Auth Fixes (#2569)
* fix: resolve error with redirects - fixes #2529 * fix: apply validations to username for oidc * fix: converted components to function components * fix: snapshots
This commit is contained in:
committed by
Kim Gardner
parent
64f102e6d4
commit
921461008e
@@ -28,7 +28,6 @@ it("renders fully", () => {
|
||||
facebook: {
|
||||
enabled: true,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/facebook",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -36,7 +35,6 @@ it("renders fully", () => {
|
||||
google: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/google",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -44,7 +42,6 @@ it("renders fully", () => {
|
||||
oidc: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/oidc",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -90,7 +87,6 @@ it("renders without logout button", () => {
|
||||
facebook: {
|
||||
enabled: true,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/facebook",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -98,7 +94,6 @@ it("renders without logout button", () => {
|
||||
google: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/google",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -106,7 +101,6 @@ it("renders without logout button", () => {
|
||||
oidc: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/oidc",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -152,7 +146,6 @@ it("renders sso only", () => {
|
||||
facebook: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/facebook",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -160,7 +153,6 @@ it("renders sso only", () => {
|
||||
google: {
|
||||
enabled: true,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/google",
|
||||
targetFilter: {
|
||||
stream: false,
|
||||
},
|
||||
@@ -168,7 +160,6 @@ it("renders sso only", () => {
|
||||
oidc: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/oidc",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -214,7 +205,6 @@ it("renders sso only without logout button", () => {
|
||||
facebook: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/facebook",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -222,7 +212,6 @@ it("renders sso only without logout button", () => {
|
||||
google: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/google",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -230,7 +219,6 @@ it("renders sso only without logout button", () => {
|
||||
oidc: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/oidc",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -276,7 +264,6 @@ it("renders without register button", () => {
|
||||
facebook: {
|
||||
enabled: true,
|
||||
allowRegistration: false,
|
||||
redirectURL: "http://localhost/facebook",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
@@ -284,7 +271,6 @@ it("renders without register button", () => {
|
||||
google: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/google",
|
||||
targetFilter: {
|
||||
stream: false,
|
||||
},
|
||||
@@ -292,7 +278,6 @@ it("renders without register button", () => {
|
||||
oidc: {
|
||||
enabled: false,
|
||||
allowRegistration: true,
|
||||
redirectURL: "http://localhost/oidc",
|
||||
targetFilter: {
|
||||
stream: true,
|
||||
},
|
||||
|
||||
@@ -71,39 +71,10 @@ export class UserBoxContainer extends Component<Props> {
|
||||
].some(i => i.enabled && i.targetFilter.stream);
|
||||
}
|
||||
|
||||
private get authUrl(): string {
|
||||
const {
|
||||
facebook,
|
||||
google,
|
||||
local,
|
||||
oidc,
|
||||
} = this.props.settings.auth.integrations;
|
||||
|
||||
const defaultAuthUrl = `${urls.embed.auth}?view=${
|
||||
this.props.local.authPopup.view
|
||||
}`;
|
||||
|
||||
if (local.enabled && local.targetFilter.stream) {
|
||||
return defaultAuthUrl;
|
||||
}
|
||||
|
||||
// For each of these integrations, if only one is enabled for the stream,
|
||||
// then return the redirectURL for that one only.
|
||||
const integrations = [facebook, google, oidc];
|
||||
const enabled = integrations.filter(
|
||||
integration => integration.enabled && integration.targetFilter.stream
|
||||
);
|
||||
if (enabled.length === 1 && enabled[0].redirectURL) {
|
||||
return enabled[0].redirectURL;
|
||||
}
|
||||
|
||||
return defaultAuthUrl;
|
||||
}
|
||||
|
||||
public render() {
|
||||
const {
|
||||
local: {
|
||||
authPopup: { open, focus },
|
||||
authPopup: { open, focus, view },
|
||||
},
|
||||
viewer,
|
||||
} = this.props;
|
||||
@@ -125,13 +96,14 @@ export class UserBoxContainer extends Component<Props> {
|
||||
return (
|
||||
<>
|
||||
<Popup
|
||||
href={this.authUrl}
|
||||
href={`${urls.embed.auth}?view=${view}`}
|
||||
title="Coral Auth"
|
||||
open={open}
|
||||
focus={focus}
|
||||
onFocus={this.handleFocus}
|
||||
onBlur={this.handleBlur}
|
||||
onClose={this.handleClose}
|
||||
features={{ width: 350, innerWidth: 350 }}
|
||||
/>
|
||||
<UserBoxUnauthenticated
|
||||
onSignIn={this.handleSignIn}
|
||||
@@ -182,7 +154,6 @@ const enhanced = withSignOutMutation(
|
||||
oidc {
|
||||
enabled
|
||||
allowRegistration
|
||||
redirectURL
|
||||
targetFilter {
|
||||
stream
|
||||
}
|
||||
@@ -190,7 +161,6 @@ const enhanced = withSignOutMutation(
|
||||
google {
|
||||
enabled
|
||||
allowRegistration
|
||||
redirectURL
|
||||
targetFilter {
|
||||
stream
|
||||
}
|
||||
@@ -198,7 +168,6 @@ const enhanced = withSignOutMutation(
|
||||
facebook {
|
||||
enabled
|
||||
allowRegistration
|
||||
redirectURL
|
||||
targetFilter {
|
||||
stream
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
exports[`renders fully 1`] = `
|
||||
<React.Fragment>
|
||||
<Popup
|
||||
features={
|
||||
Object {
|
||||
"innerWidth": 350,
|
||||
"width": 350,
|
||||
}
|
||||
}
|
||||
focus={false}
|
||||
href="/embed/auth?view=SIGN_IN"
|
||||
onBlur={[Function]}
|
||||
@@ -26,6 +32,12 @@ exports[`renders sso only without logout button 1`] = `null`;
|
||||
exports[`renders without logout button 1`] = `
|
||||
<React.Fragment>
|
||||
<Popup
|
||||
features={
|
||||
Object {
|
||||
"innerWidth": 350,
|
||||
"width": 350,
|
||||
}
|
||||
}
|
||||
focus={false}
|
||||
href="/embed/auth?view=SIGN_IN"
|
||||
onBlur={[Function]}
|
||||
@@ -45,6 +57,12 @@ exports[`renders without logout button 1`] = `
|
||||
exports[`renders without register button 1`] = `
|
||||
<React.Fragment>
|
||||
<Popup
|
||||
features={
|
||||
Object {
|
||||
"innerWidth": 350,
|
||||
"width": 350,
|
||||
}
|
||||
}
|
||||
focus={false}
|
||||
href="/embed/auth?view=SIGN_IN"
|
||||
onBlur={[Function]}
|
||||
|
||||
Reference in New Issue
Block a user