Prevent signin without hosted domain
This commit is contained in:
parent
25aa1f288b
commit
aa9ed09f08
|
@ -14,7 +14,7 @@ DEPLOYMENT=self
|
||||||
ENABLE_UPDATES=true
|
ENABLE_UPDATES=true
|
||||||
DEBUG=sql,cache,presenters,events
|
DEBUG=sql,cache,presenters,events
|
||||||
|
|
||||||
# Slack signin credentials (at least one is required)
|
# Third party signin credentials (at least one is required)
|
||||||
SLACK_KEY=71315967491.XXXXXXXXXX
|
SLACK_KEY=71315967491.XXXXXXXXXX
|
||||||
SLACK_SECRET=d2dc414f9953226bad0a356cXXXXYYYY
|
SLACK_SECRET=d2dc414f9953226bad0a356cXXXXYYYY
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,9 @@ class AuthStore {
|
||||||
this.user = data.user;
|
this.user = data.user;
|
||||||
this.team = data.team;
|
this.team = data.team;
|
||||||
this.oauthState = data.oauthState;
|
this.oauthState = data.oauthState;
|
||||||
|
|
||||||
|
// load token from state for backwards compatability with
|
||||||
|
// sessions created pre-google auth
|
||||||
this.token = Cookie.get('accessToken') || data.token;
|
this.token = Cookie.get('accessToken') || data.token;
|
||||||
|
|
||||||
autorun(() => {
|
autorun(() => {
|
||||||
|
|
2
index.js
2
index.js
|
@ -8,7 +8,7 @@ if (process.env.NODE_ENV === 'production') {
|
||||||
} else if (process.env.NODE_ENV === 'development') {
|
} else if (process.env.NODE_ENV === 'development') {
|
||||||
console.log(
|
console.log(
|
||||||
'\n\x1b[33m%s\x1b[0m',
|
'\n\x1b[33m%s\x1b[0m',
|
||||||
'Running Outline in development mode with React hot reloading. To run Outline in production mode, use `yarn start`'
|
'Running Outline in development mode with hot reloading. To run Outline in production mode, use `yarn start`'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,11 @@ router.get('google.callback', async ctx => {
|
||||||
url: 'https://www.googleapis.com/oauth2/v1/userinfo',
|
url: 'https://www.googleapis.com/oauth2/v1/userinfo',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!profile.data.hd) {
|
||||||
|
ctx.redirect('/?notice=google-hd');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const teamName = capitalize(profile.data.hd.split('.')[0]);
|
const teamName = capitalize(profile.data.hd.split('.')[0]);
|
||||||
const [team, isFirstUser] = await Team.findOrCreate({
|
const [team, isFirstUser] = await Team.findOrCreate({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { developers, githubUrl } from '../../shared/utils/routeHelpers';
|
||||||
import { color } from '../../shared/styles/constants';
|
import { color } from '../../shared/styles/constants';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
notice?: 'google-hd',
|
||||||
lastSignedIn: string,
|
lastSignedIn: string,
|
||||||
googleSigninEnabled: boolean,
|
googleSigninEnabled: boolean,
|
||||||
slackSigninEnabled: boolean,
|
slackSigninEnabled: boolean,
|
||||||
|
@ -31,6 +32,12 @@ function Home(props: Props) {
|
||||||
<p>
|
<p>
|
||||||
<SigninButtons {...props} />
|
<SigninButtons {...props} />
|
||||||
</p>
|
</p>
|
||||||
|
{props.notice === 'google-hd' && (
|
||||||
|
<Notice>
|
||||||
|
Sorry, Google sign in cannot be used with a personal email. Please
|
||||||
|
try signing in with your company Google account.
|
||||||
|
</Notice>
|
||||||
|
)}
|
||||||
</Hero>
|
</Hero>
|
||||||
<Features reverse={{ mobile: true, tablet: false, desktop: false }}>
|
<Features reverse={{ mobile: true, tablet: false, desktop: false }}>
|
||||||
<Grid.Unit size={{ desktop: 1 / 3, tablet: 1 / 2 }}>
|
<Grid.Unit size={{ desktop: 1 / 3, tablet: 1 / 2 }}>
|
||||||
|
@ -107,6 +114,13 @@ function Home(props: Props) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Notice = styled.p`
|
||||||
|
background: #ffd95c;
|
||||||
|
color: hsla(46, 100%, 20%, 1);
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
`;
|
||||||
|
|
||||||
const Screenshot = styled.img`
|
const Screenshot = styled.img`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
box-shadow: 0 0 80px 0 rgba(124, 124, 124, 0.5),
|
box-shadow: 0 0 80px 0 rgba(124, 124, 124, 0.5),
|
||||||
|
|
|
@ -71,6 +71,7 @@ router.get('/', async ctx => {
|
||||||
await renderpage(
|
await renderpage(
|
||||||
ctx,
|
ctx,
|
||||||
<Home
|
<Home
|
||||||
|
notice={ctx.request.query.notice}
|
||||||
lastSignedIn={lastSignedIn}
|
lastSignedIn={lastSignedIn}
|
||||||
googleSigninEnabled={!!process.env.GOOGLE_CLIENT_ID}
|
googleSigninEnabled={!!process.env.GOOGLE_CLIENT_ID}
|
||||||
slackSigninEnabled={!!process.env.SLACK_KEY}
|
slackSigninEnabled={!!process.env.SLACK_KEY}
|
||||||
|
|
Reference in New Issue