Skip to content

Commit

Permalink
Release v4.7.1 (hotfix)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinejaussoin authored Sep 27, 2021
1 parent bca078a commit 9453f69
Show file tree
Hide file tree
Showing 24 changed files with 76 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Alpha Build'

on:
push:
branches: [v470/release]
branches: [v471/bugfix]

jobs:
build:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ When using the Docker deployment, your database runs from a container. But if yo

## Versions History

### Version 4.7.1 (hotfix)

- 🐛 Fixed a bug highlighted by Sentry, where anonymous account without a password would trigger an exception.

### Version 4.7.0

- Account Federation: all accounts with the same email address are now a unique account (sharing sessions, etc.). If you owned multiple accounts with the same email address (for instance one via Google OAuth and another via GitHub), they will be merged into a single account.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.7.0
4.7.1
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@retrospected/backend",
"version": "4.7.0",
"version": "4.7.1",
"license": "GNU GPLv3",
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/auth/logins/anonymous-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export default async function loginAnonymous(
username: string,
password: string
): Promise<UserIdentityEntity | null> {
const identity = registerAnonymousUser(username, password);
const identity = await registerAnonymousUser(username, password);
return identity;
}
2 changes: 1 addition & 1 deletion backend/src/auth/passport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default () => {
.replace('__ANONUSER', '');
const identity = await loginAnonymous(actualUsername, password);
done(
!identity ? 'Anonymous account not valid' : null,
identity ? null : 'Anonymous account not valid',
identity ? identity.toIds() : undefined
);
} else {
Expand Down
5 changes: 3 additions & 2 deletions backend/src/db/actions/licences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { transaction } from './transaction';
import LicenceEntity from '../entities/Licence';
import { v4 } from 'uuid';
import { sendSelfHostWelcome } from '../../email/emailSender';
import { LicenceRepository } from '../repositories';

export async function registerLicence(
email: string | null,
Expand All @@ -10,11 +11,11 @@ export async function registerLicence(
sessionId: string
): Promise<boolean> {
return await transaction(async (manager) => {
const repository = manager.getRepository(LicenceEntity);
const repository = manager.getCustomRepository(LicenceRepository);
const key = v4();
const licence = new LicenceEntity(v4(), email, key, customerId, sessionId);
try {
const savedLicence = await repository.save(licence);
const savedLicence = await repository.saveAndReload(licence);
if (savedLicence) {
if (email) {
await sendSelfHostWelcome(email, name || '', key);
Expand Down
4 changes: 2 additions & 2 deletions backend/src/db/actions/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async function getOrCreateUser(
}
const user = new UserEntity(v4(), '');
user.email = email;
return await userRepository.save(user);
return await userRepository.saveAndReload(user);
}

async function updateUserPassword(
Expand All @@ -325,7 +325,7 @@ async function updateUserPassword(
const identityRepo = manager.getCustomRepository(UserIdentityRepository);
const existingUser = await identityRepo.findOne(identityId);
if (existingUser) {
return await identityRepo.save({
return await identityRepo.saveAndReload({
...existingUser,
password,
});
Expand Down
13 changes: 13 additions & 0 deletions backend/src/db/repositories/BaseRepository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { DeepPartial, Repository, SaveOptions } from 'typeorm';
import { Entity } from '@retrospected/common';

export default class BaseRepository<T extends Entity> extends Repository<T> {
async saveAndReload(
entity: DeepPartial<T>,
options?: SaveOptions
): Promise<T> {
const saved = await this.save(entity, options);
const reloaded = await this.findOne(saved.id);
return reloaded!;
}
}
5 changes: 3 additions & 2 deletions backend/src/db/repositories/ColumnRepository.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { EntityRepository, Repository } from 'typeorm';
import { EntityRepository } from 'typeorm';
import { ColumnDefinitionEntity } from '../entities';
import { ColumnDefinition as JsonColumnDefinition } from '@retrospected/common';
import { v4 } from 'uuid';
import BaseRepository from './BaseRepository';

@EntityRepository(ColumnDefinitionEntity)
export default class ColumnDefinitionRepository extends Repository<ColumnDefinitionEntity> {
export default class ColumnDefinitionRepository extends BaseRepository<ColumnDefinitionEntity> {
async saveFromJson(
colDef: JsonColumnDefinition,
sessionId: string
Expand Down
6 changes: 6 additions & 0 deletions backend/src/db/repositories/LicenceRepository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { EntityRepository } from 'typeorm';
import LicenceEntity from '../entities/Licence';
import BaseRepository from './BaseRepository';

@EntityRepository(LicenceEntity)
export default class LicenceRepository extends BaseRepository<LicenceEntity> {}
8 changes: 4 additions & 4 deletions backend/src/db/repositories/PostGroupRepository.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { EntityRepository, Repository } from 'typeorm';
import { EntityRepository } from 'typeorm';
import { PostGroupEntity } from '../entities';
import { PostGroup as JsonPostGroup } from '@retrospected/common';
import { cloneDeep } from 'lodash';
import BaseRepository from './BaseRepository';

@EntityRepository(PostGroupEntity)
export default class PostGroupRepository extends Repository<PostGroupEntity> {
export default class PostGroupRepository extends BaseRepository<PostGroupEntity> {
async saveFromJson(
sessionId: string,
authorId: string,
Expand All @@ -18,7 +19,6 @@ export default class PostGroupRepository extends Repository<PostGroupEntity> {
};
delete groupWithoutPosts.posts;

await this.save(groupWithoutPosts);
return this.findOne(groupWithoutPosts.id);
return await this.saveAndReload(groupWithoutPosts);
}
}
11 changes: 5 additions & 6 deletions backend/src/db/repositories/PostRepository.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { EntityRepository, Repository } from 'typeorm';
import { EntityRepository } from 'typeorm';
import { SessionEntity, PostEntity } from '../entities';
import SessionRepository from './SessionRepository';
import { Post as JsonPost, defaultSession } from '@retrospected/common';
import { cloneDeep } from 'lodash';
import BaseRepository from './BaseRepository';

@EntityRepository(PostEntity)
export default class PostRepository extends Repository<PostEntity> {
export default class PostRepository extends BaseRepository<PostEntity> {
async updateFromJson(
sessionId: string,
post: JsonPost
): Promise<PostEntity | undefined> {
await this.save({
return await this.saveAndReload({
...cloneDeep(post),
session: {
id: sessionId,
Expand All @@ -25,7 +26,6 @@ export default class PostRepository extends Repository<PostEntity> {
}
: null,
});
return await this.findOne(post.id);
}
async saveFromJson(
sessionId: string,
Expand All @@ -34,7 +34,7 @@ export default class PostRepository extends Repository<PostEntity> {
): Promise<PostEntity | undefined> {
const session = await this.manager.findOne(SessionEntity, sessionId);
if (session) {
await this.save({
return await this.saveAndReload({
...cloneDeep(post),
user: {
id: userId,
Expand All @@ -48,7 +48,6 @@ export default class PostRepository extends Repository<PostEntity> {
}
: null,
});
return await this.findOne(post.id);
} else {
const sessionRepository =
this.manager.getCustomRepository(SessionRepository);
Expand Down
8 changes: 4 additions & 4 deletions backend/src/db/repositories/SessionRepository.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { EntityRepository, Repository } from 'typeorm';
import { EntityRepository } from 'typeorm';
import { SessionEntity } from '../entities';
import ColumnRepository from './ColumnRepository';
import { Session as JsonSession, SessionOptions } from '@retrospected/common';
import BaseRepository from './BaseRepository';

@EntityRepository(SessionEntity)
export default class SessionRepository extends Repository<SessionEntity> {
export default class SessionRepository extends BaseRepository<SessionEntity> {
async updateOptions(
sessionId: string,
options: SessionOptions
Expand Down Expand Up @@ -40,8 +41,7 @@ export default class SessionRepository extends Repository<SessionEntity> {
delete sessionWithoutPosts.columns;

const columnsRepo = this.manager.getCustomRepository(ColumnRepository);
await this.save(sessionWithoutPosts);
const createdSession = (await this.findOne(sessionWithoutPosts.id))!;
const createdSession = await this.saveAndReload(sessionWithoutPosts);
for (let i = 0; i < session.columns.length; i++) {
await columnsRepo.saveFromJson(session.columns[i], session.id);
}
Expand Down
5 changes: 3 additions & 2 deletions backend/src/db/repositories/SessionTemplateRepository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EntityRepository, Repository } from 'typeorm';
import { EntityRepository } from 'typeorm';
import { SessionTemplateEntity } from '../entities';
import {
SessionTemplate as JsonSessionTemplate,
Expand All @@ -7,9 +7,10 @@ import {
} from '@retrospected/common';
import { v4 } from 'uuid';
import { TemplateColumnRepository } from '.';
import BaseRepository from './BaseRepository';

@EntityRepository(SessionTemplateEntity)
export default class SessionTemplateRepository extends Repository<SessionTemplateEntity> {
export default class SessionTemplateRepository extends BaseRepository<SessionTemplateEntity> {
async saveFromJson(
name: string,
columns: JsonColumnDefinition[],
Expand Down
11 changes: 6 additions & 5 deletions backend/src/db/repositories/SubscriptionRepository.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { EntityRepository, Repository } from 'typeorm';
import { EntityRepository } from 'typeorm';
import { UserEntity, SubscriptionEntity } from '../entities';
import { Plan } from '@retrospected/common';
import BaseRepository from './BaseRepository';
@EntityRepository(SubscriptionEntity)
export default class SubscriptionRepository extends Repository<SubscriptionEntity> {
export default class SubscriptionRepository extends BaseRepository<SubscriptionEntity> {
async activate(
stripeSubscriptionId: string,
owner: UserEntity,
Expand All @@ -19,11 +20,11 @@ export default class SubscriptionRepository extends Repository<SubscriptionEntit
);
newSubscription.domain = domain;
newSubscription.active = true;
return await this.save(newSubscription);
return await this.saveAndReload(newSubscription);
}
existingSub.active = true;
existingSub.domain = domain;
return await this.save(existingSub);
return await this.saveAndReload(existingSub);
}

async cancel(stripeSubscriptionId: string): Promise<SubscriptionEntity> {
Expand All @@ -32,6 +33,6 @@ export default class SubscriptionRepository extends Repository<SubscriptionEntit
throw Error('Cannot cancel a subscription that does not exist');
}
existingSub.active = false;
return await this.save(existingSub);
return await this.saveAndReload(existingSub);
}
}
5 changes: 3 additions & 2 deletions backend/src/db/repositories/TemplateColumnRepository.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { EntityRepository, Repository } from 'typeorm';
import { EntityRepository } from 'typeorm';
import { TemplateColumnDefinitionEntity } from '../entities';
import { ColumnDefinition as JsonColumnDefinition } from '@retrospected/common';
import { v4 } from 'uuid';
import BaseRepository from './BaseRepository';

@EntityRepository(TemplateColumnDefinitionEntity)
export default class TemplateColumnDefinitionRepository extends Repository<TemplateColumnDefinitionEntity> {
export default class TemplateColumnDefinitionRepository extends BaseRepository<TemplateColumnDefinitionEntity> {
async saveFromJson(
colDef: JsonColumnDefinition,
templateId: string
Expand Down
5 changes: 3 additions & 2 deletions backend/src/db/repositories/UserIdentityRepository.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EntityRepository, Repository } from 'typeorm';
import { EntityRepository } from 'typeorm';
import UserIdentityEntity from '../entities/UserIdentity';
import BaseRepository from './BaseRepository';

@EntityRepository(UserIdentityEntity)
export default class UserIdentityRepository extends Repository<UserIdentityEntity> {}
export default class UserIdentityRepository extends BaseRepository<UserIdentityEntity> {}
9 changes: 5 additions & 4 deletions backend/src/db/repositories/UserRepository.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { EntityRepository, Repository } from 'typeorm';
import { EntityRepository } from 'typeorm';
import { UserEntity } from '../entities';
import { FullUser, User as JsonUser } from '@retrospected/common';
import { addDays } from 'date-fns';
import BaseRepository from './BaseRepository';

@EntityRepository(UserEntity)
export default class UserRepository extends Repository<UserEntity> {
export default class UserRepository extends BaseRepository<UserEntity> {
async saveFromJson(user: JsonUser): Promise<UserEntity> {
return await this.save(user);
return await this.saveAndReload(user);
}
async persistTemplate(userId: string, templateId: string): Promise<void> {
await this.update({ id: userId }, { defaultTemplate: { id: templateId } });
Expand All @@ -16,7 +17,7 @@ export default class UserRepository extends Repository<UserEntity> {
const userEntity = await this.findOne(user.id);
if (userEntity && !userEntity.trial && !user.pro) {
userEntity.trial = addDays(new Date(), 30);
return await this.save(userEntity);
return await this.saveAndReload(userEntity);
}
return null;
}
Expand Down
5 changes: 3 additions & 2 deletions backend/src/db/repositories/VoteRepository.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { EntityRepository, Repository } from 'typeorm';
import { EntityRepository } from 'typeorm';
import { VoteEntity } from '../entities';
import { Vote as JsonVote } from '@retrospected/common';
import BaseRepository from './BaseRepository';

@EntityRepository(VoteEntity)
export default class VoteRepository extends Repository<VoteEntity> {
export default class VoteRepository extends BaseRepository<VoteEntity> {
async saveFromJson(
postId: string,
userId: string,
Expand Down
1 change: 1 addition & 0 deletions backend/src/db/repositories/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export { default as SessionTemplateRepository } from './SessionTemplateRepositor
export { default as TemplateColumnRepository } from './TemplateColumnRepository';
export { default as SubscriptionRepository } from './SubscriptionRepository';
export { default as UserIdentityRepository } from './UserIdentityRepository';
export { default as LicenceRepository } from './LicenceRepository';
2 changes: 1 addition & 1 deletion common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@retrospected/common",
"version": "4.7.0",
"version": "4.7.1",
"license": "GNU GPLv3",
"private": true,
"main": "dist/src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@retrospected/frontend",
"version": "4.7.0",
"version": "4.7.1",
"license": "GNU GPLv3",
"private": true,
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "retrospected",
"version": "4.7.0",
"version": "4.7.1",
"description": "An agile retrospective board - Powering www.retrospected.com",
"private": true,
"workspaces": [
Expand Down

0 comments on commit 9453f69

Please sign in to comment.