Compare commits
No commits in common. "main" and "c64387668de1fd633a1759ab1bda5a914848f3da" have entirely different histories.
main
...
c64387668d
21
.drone.yml
21
.drone.yml
|
@ -1,21 +0,0 @@
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: linters
|
|
||||||
steps:
|
|
||||||
- name: publish image
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
username: thecoopcloud
|
|
||||||
password:
|
|
||||||
from_secret: thecoopcloud_password
|
|
||||||
repo: thecoopcloud/outline-with-patch
|
|
||||||
tags: latest
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
branch:
|
|
||||||
- main
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
} from "../errors";
|
} from "../errors";
|
||||||
import mailer from "../mailer";
|
import mailer from "../mailer";
|
||||||
import { Collection, Team, User } from "../models";
|
import { Collection, Team, User } from "../models";
|
||||||
import teamCreator, { findExistingTeam } from "./teamCreator";
|
import teamCreator from "./teamCreator";
|
||||||
import userCreator from "./userCreator";
|
import userCreator from "./userCreator";
|
||||||
|
|
||||||
type Props = {|
|
type Props = {|
|
||||||
|
@ -53,15 +53,13 @@ export default async function accountProvisioner({
|
||||||
}: Props): Promise<AccountProvisionerResult> {
|
}: Props): Promise<AccountProvisionerResult> {
|
||||||
let result;
|
let result;
|
||||||
try {
|
try {
|
||||||
result =
|
result = await teamCreator({
|
||||||
(await findExistingTeam(authenticationProviderParams)) ||
|
name: teamParams.name,
|
||||||
(await teamCreator({
|
domain: teamParams.domain,
|
||||||
name: teamParams.name,
|
subdomain: teamParams.subdomain,
|
||||||
domain: teamParams.domain,
|
avatarUrl: teamParams.avatarUrl,
|
||||||
subdomain: teamParams.subdomain,
|
authenticationProvider: authenticationProviderParams,
|
||||||
avatarUrl: teamParams.avatarUrl,
|
});
|
||||||
authenticationProvider: authenticationProviderParams,
|
|
||||||
}));
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new AuthenticationError(err.message);
|
throw new AuthenticationError(err.message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,44 +12,6 @@ type TeamCreatorResult = {|
|
||||||
isNewTeam: boolean,
|
isNewTeam: boolean,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
export async function findExistingTeam(authenticationProvider: {|
|
|
||||||
name: string,
|
|
||||||
providerId: string,
|
|
||||||
|}): Promise<TeamCreatorResult | null> {
|
|
||||||
// Should outline deployed in a multi-tenant environment, skip searching
|
|
||||||
// for an existing team.
|
|
||||||
if (process.env.DEPLOYMENT === "hosted") return null;
|
|
||||||
|
|
||||||
// get the first team that exists, ordered by createdAt
|
|
||||||
const team = await Team.findOne({ limit: 1, order: ["createdAt"] });
|
|
||||||
if (team === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// query if a corresponding authenticationProvider already exists
|
|
||||||
let authenticationProviders = await team.getAuthenticationProviders({
|
|
||||||
where: {
|
|
||||||
name: authenticationProvider.name,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// ... if this is not the case, create a new authentication provider
|
|
||||||
// that we use instead, overwriting the providerId with the domain of the team
|
|
||||||
let authP =
|
|
||||||
authenticationProviders.length === 0
|
|
||||||
? await team.createAuthenticationProvider({
|
|
||||||
...authenticationProvider,
|
|
||||||
providerId: team.domain,
|
|
||||||
})
|
|
||||||
: authenticationProviders[0];
|
|
||||||
|
|
||||||
return {
|
|
||||||
authenticationProvider: authP,
|
|
||||||
team: team,
|
|
||||||
isNewTeam: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async function teamCreator({
|
export default async function teamCreator({
|
||||||
name,
|
name,
|
||||||
domain,
|
domain,
|
||||||
|
|
Reference in New Issue