Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update USER_CREATED flag on sign-up, enable initial sign-up on EE, hide thrid-party authentication from EE, password reset styling improvement #3326

Merged
merged 9 commits into from Dec 3, 2023
Merged
@@ -1,12 +1,11 @@
import { ApFlagId, PrincipalType, Project, ProjectType, User } from '@activepieces/shared'
import { PrincipalType, Project, ProjectType, User } from '@activepieces/shared'
import { projectService } from '../../../project/project-service'
import { flagService } from '../../../flags/flag.service'
import { AuthenticationServiceHooks } from './authentication-service-hooks'
import { accessTokenManager } from '../../lib/access-token-manager'

export const communityAuthenticationServiceHooks: AuthenticationServiceHooks = {
async postSignUp({ user }) {
await flagService.save({ id: ApFlagId.USER_CREATED, value: true })

const project = await projectService.create({
displayName: `${user.firstName}'s Project`,
ownerId: user.id,
Expand Down
Expand Up @@ -23,7 +23,7 @@ export const authenticationService = {
})

const userWithoutPassword = removePasswordPropFromUser(authnResponse.user)

await flagService.save({ id: ApFlagId.USER_CREATED, value: true })
await sendTelemetry({
user, project: authnResponse.project,
})
Expand Down
Expand Up @@ -29,12 +29,14 @@ export const enterpriseAuthenticationServiceHooks: AuthenticationServiceHooks =
type: ProjectType.STANDALONE,
})

await platformService.add({
const platform = await platformService.add({
ownerId: user.id,
projectId: project.id,
name: DEFAULT_PLATFORM_NAME,
})

await userService.updatePlatformId({ id: user.id, platformId: platform.id })

await flagService.save({
id: ApFlagId.PLATFORM_CREATED,
value: true,
Expand Down
14 changes: 8 additions & 6 deletions packages/backend/src/app/ee/flags/enterprise-flags.hooks.ts
@@ -1,10 +1,11 @@
import { ApFlagId, isNil } from '@activepieces/shared'
import { ApEdition, ApFlagId, isNil } from '@activepieces/shared'
import { FlagsServiceHooks } from '../../flags/flags.hooks'
import { apperanceHelper } from '../helper/apperance-helper'
import { platformService } from '../platform/platform.service'
import { ThirdPartyAuthnProviderEnum } from '@activepieces/ee-shared'
import { resolvePlatformIdForRequest } from '../platform/lib/platform-utils'

import { getEdition } from '../../helper/secret-helper'
const edition = getEdition()
export const enterpriseFlagsHooks: FlagsServiceHooks = {
async modify({ flags, request }) {
const modifiedFlags = { ...flags }
Expand All @@ -17,10 +18,11 @@ export const enterpriseFlagsHooks: FlagsServiceHooks = {
modifiedFlags[ApFlagId.SHOW_COMMUNITY] = false
modifiedFlags[ApFlagId.SHOW_DOCS] = false
modifiedFlags[ApFlagId.SHOW_BILLING] = false
modifiedFlags[ApFlagId.THIRD_PARTY_AUTH_PROVIDERS_TO_SHOW_MAP] = {
[ThirdPartyAuthnProviderEnum.GOOGLE]: false,
[ThirdPartyAuthnProviderEnum.GITHUB]: false,
}
modifiedFlags[ApFlagId.THIRD_PARTY_AUTH_PROVIDERS_TO_SHOW_MAP] = edition === ApEdition.ENTERPRISE ?
modifiedFlags[ApFlagId.THIRD_PARTY_AUTH_PROVIDERS_TO_SHOW_MAP] : {
[ThirdPartyAuthnProviderEnum.GOOGLE]: false,
[ThirdPartyAuthnProviderEnum.GITHUB]: false,
},
modifiedFlags[ApFlagId.SHOW_BLOG_GUIDE] = false
modifiedFlags[ApFlagId.SHOW_COMMUNITY_PIECES] = false
modifiedFlags[ApFlagId.SHOW_POWERED_BY_AP] = platform.showPoweredBy
Expand Down
Expand Up @@ -30,8 +30,8 @@ import {
import { buildPaginator } from '../../helper/pagination/build-paginator'
import { projectService } from '../../project/project-service'
import { emailService } from '../helper/email/email-service'
import { getEdition } from '../../helper/secret-helper'
import { projectMembersLimit } from '../billing/limits/members-limit'
import { getEdition } from '../../helper/secret-helper'

const projectMemberRepo = databaseConnection.getRepository(ProjectMemberEntity)

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/common/src/lib/service/flag.service.ts
Expand Up @@ -53,7 +53,7 @@ export class FlagService {
return this.getAllFlags().pipe(
map((flags) => {
const firstUser = flags['USER_CREATED'] as boolean;
if (!firstUser && flags['EDITION'] === ApEdition.COMMUNITY) {
if (!firstUser && flags['EDITION'] !== ApEdition.CLOUD) {
abuaboud marked this conversation as resolved.
Show resolved Hide resolved
return true;
}
return flags['SIGN_UP_ENABLED'] as boolean;
Expand Down
Expand Up @@ -72,7 +72,8 @@

</mat-menu>

<p @fadeInUp class="ap-text-danger ap-text-center" *ngIf="passwordResetActionError">{{ passwordResetActionError }}
<p @fadeInUp class="ap-text-danger ap-text-center ap-mb-2" *ngIf="passwordResetActionError">{{ passwordResetActionError
}}
</p>

<div class="text-center">
Expand Down
@@ -1,7 +1,7 @@
import { Component } from '@angular/core';
import { FormControl, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable, catchError, tap } from 'rxjs';
import { Observable, catchError, of, tap } from 'rxjs';

import {
containsSpecialCharacter,
Expand Down Expand Up @@ -55,12 +55,13 @@ export class ResetPasswordComponent {
userId,
})
.pipe(
tap(() => this.router.navigate(['/sign-in'])),
catchError((err) => {
this.passwordResetActionError = $localize`Your password reset request has expired, please request a new one`;
this.resetingPassword = false;
console.error(err);
throw err;
}),
tap(() => this.router.navigate(['/sign-in']))
return of(void 0);
})
);
}
}
Expand Down