Skip to content

Commit e1697dc

Browse files
authored
Merge pull request #337 from TaloDev/develop
Release 0.43.0
2 parents 0f1a755 + 50b783d commit e1697dc

File tree

14 files changed

+258
-15
lines changed

14 files changed

+258
-15
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
uses: appleboy/ssh-action@master
4848
with:
4949
host: ${{ secrets.HOST }}
50-
host_port: ${{ secrets.PORT }}
50+
port: ${{ secrets.PORT }}
5151
username: ${{ secrets.USERNAME }}
5252
key: ${{ secrets.KEY }}
5353
passphrase: ${{ secrets.PASSPHRASE }}

package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "game-services",
3-
"version": "0.42.0",
3+
"version": "0.43.0",
44
"description": "",
55
"main": "src/index.ts",
66
"scripts": {

src/docs/player-auth-api.docs.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,27 @@ const PlayerAuthAPIDocs: APIDocs<PlayerAuthAPIService> = {
276276
}
277277
}
278278
]
279+
},
280+
delete: {
281+
description: 'Delete a player account',
282+
params: {
283+
headers: {
284+
'x-talo-player': 'The ID of the player',
285+
'x-talo-alias': 'The ID of the player\'s alias',
286+
'x-talo-session': 'The session token'
287+
},
288+
body: {
289+
currentPassword: 'The current password of the player'
290+
}
291+
},
292+
samples: [
293+
{
294+
title: 'Sample request',
295+
sample: {
296+
currentPassword: 'password'
297+
}
298+
}
299+
]
279300
}
280301
}
281302

src/entities/player-alias.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Cascade, Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/mysql'
1+
import { Cascade, Entity, Filter, ManyToOne, PrimaryKey, Property } from '@mikro-orm/mysql'
22
import Player from './player'
33

44
export enum PlayerAliasService {
@@ -11,6 +11,7 @@ export enum PlayerAliasService {
1111
}
1212

1313
@Entity()
14+
@Filter({ name: 'notAnonymised', cond: { anonymised: false }, default: true })
1415
export default class PlayerAlias {
1516
@PrimaryKey()
1617
id: number
@@ -24,6 +25,9 @@ export default class PlayerAlias {
2425
@ManyToOne(() => Player, { cascade: [Cascade.REMOVE], eager: true })
2526
player: Player
2627

28+
@Property({ default: false })
29+
anonymised: boolean
30+
2731
@Property()
2832
createdAt: Date = new Date()
2933

src/entities/player-auth-activity.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export enum PlayerAuthActivityType {
1515
VERFICIATION_TOGGLED,
1616
CHANGE_PASSWORD_FAILED,
1717
CHANGE_EMAIL_FAILED,
18-
TOGGLE_VERIFICATION_FAILED
18+
TOGGLE_VERIFICATION_FAILED,
19+
DELETED_AUTH,
20+
DELETE_AUTH_FAILED
1921
}
2022

2123
@Entity()
@@ -76,6 +78,10 @@ export default class PlayerAuthActivity {
7678
return `${authAlias.identifier} failed to change their email`
7779
case PlayerAuthActivityType.TOGGLE_VERIFICATION_FAILED:
7880
return `${authAlias.identifier} failed to toggle verification`
81+
case PlayerAuthActivityType.DELETED_AUTH:
82+
return `${authAlias.identifier} deleted their account`
83+
case PlayerAuthActivityType.DELETE_AUTH_FAILED:
84+
return `${authAlias.identifier} failed to delete their account`
7985
default:
8086
return ''
8187
}

src/migrations/.snapshot-gs_dev.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,17 @@
12301230
"length": 255,
12311231
"mappedType": "string"
12321232
},
1233+
"anonymised": {
1234+
"name": "anonymised",
1235+
"type": "tinyint(1)",
1236+
"unsigned": false,
1237+
"autoincrement": false,
1238+
"primary": false,
1239+
"nullable": false,
1240+
"length": 1,
1241+
"default": "false",
1242+
"mappedType": "boolean"
1243+
},
12331244
"created_at": {
12341245
"name": "created_at",
12351246
"type": "datetime",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Migration } from '@mikro-orm/migrations'
2+
3+
export class AddPlayerAliasAnonymisedColumn extends Migration {
4+
5+
override async up(): Promise<void> {
6+
this.addSql('alter table `player_alias` add `anonymised` tinyint(1) not null default false;')
7+
}
8+
9+
override async down(): Promise<void> {
10+
this.addSql('alter table `player_alias` drop column `anonymised`;')
11+
}
12+
13+
}

src/migrations/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { AddAPIKeyUpdatedAtColumn } from './20240614122547AddAPIKeyUpdatedAtColu
2727
import { CreatePlayerAuthTable } from './20240628155142CreatePlayerAuthTable'
2828
import { CreatePlayerAuthActivityTable } from './20240725183402CreatePlayerAuthActivityTable'
2929
import { UpdatePlayerAliasServiceColumn } from './20240916213402UpdatePlayerAliasServiceColumn'
30+
import { AddPlayerAliasAnonymisedColumn } from './20240920121232AddPlayerAliasAnonymisedColumn'
3031

3132
export default [
3233
{
@@ -144,5 +145,9 @@ export default [
144145
{
145146
name: 'UpdatePlayerAliasServiceColumn',
146147
class: UpdatePlayerAliasServiceColumn
148+
},
149+
{
150+
name: 'AddPlayerAliasAnonymisedColumn',
151+
class: AddPlayerAliasAnonymisedColumn
147152
}
148153
]

src/policies/api/player-auth-api.policy.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ export default class PlayerAuthAPIPolicy extends Policy {
3838
async toggleVerification(): Promise<PolicyResponse> {
3939
return await this.hasScopes([APIKeyScope.READ_PLAYERS, APIKeyScope.WRITE_PLAYERS])
4040
}
41+
42+
async delete(): Promise<PolicyResponse> {
43+
return await this.hasScopes([APIKeyScope.READ_PLAYERS, APIKeyScope.WRITE_PLAYERS])
44+
}
4145
}

0 commit comments

Comments
 (0)