Merge remote-tracking branch 'origin/master' into eric_front_and_back

This commit is contained in:
Me
2023-01-17 12:32:05 +01:00
7 changed files with 45 additions and 23 deletions

View File

@@ -24,10 +24,12 @@ export class AuthenticationService {
if (!check_name)
return await this.userService.create(createUsersDto);
let createUsersDtoWithUsername : CreateUsersDto = createUsersDto;
let i = 0;
while (check_name === true)
{
createUsersDtoWithUsername = { ...createUsersDto, username: createUsersDto.username + randomUUID() };
createUsersDtoWithUsername = { ...createUsersDto, username: createUsersDto.username + '_' + i};
check_name = await this.userService.isUsernameExists(createUsersDtoWithUsername.username);
i++;
}
return this.userService.create(createUsersDtoWithUsername);
}

View File

@@ -372,11 +372,14 @@ export class ChatService {
async getListBlockUser(username: string): Promise<string[]>
{
printCaller("-- in ");
let users: string[] = [];
let user = await this.getUserByName(username);
let friends_users = await this.friendshipService.findAllBlockedFriends(user.id);
let users = friends_users.map(user => user.receiverUsername);
console.log("USERNAME CHAT SRVICE " + username);
let friends_users;
if (user)
friends_users = await this.friendshipService.findAllBlockedFriends(user.id);
if (friends_users)
users = friends_users.map(user => user.receiverUsername);
printCaller("-- out ");
return users;
}

View File

@@ -1,9 +1,11 @@
import { IsBoolean, IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { IsBoolean, Matches, MaxLength, IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { isSet } from 'util/types';
export class CreateUsersDto {
@IsString()
@IsNotEmpty()
@Matches(/^[a-zA-Z0-9'-_]+$/)
@MaxLength(50)
readonly username: string;
readonly fortyTwoId: string;
@IsEmail()

View File

@@ -26,6 +26,16 @@ body {
font-display: swap;
}
@font-face {
font-family: "Bit5x3";
src:
url("/fonts/Bit5x3.woff2") format("woff2"),
local("Bit5x3"),
url("/fonts/Bit5x3.woff") format("woff");
font-weight: normal;
font-style: normal;
font-display: swap;
}
a {
color: rgb(0,100,200);

View File

@@ -390,19 +390,20 @@
{/if}
{/if}
<div id="preload_font">.</div>
</div> <!-- div "game_page" -->
<style>
@font-face {
#preload_font {
font-family: "Bit5x3";
src:
url("/fonts/Bit5x3.woff2") format("woff2"),
local("Bit5x3"),
url("/fonts/Bit5x3.woff") format("woff");
font-weight: normal;
font-style: normal;
font-display: swap;
opacity:0;
height:0;
width:0;
display:inline-block;
}
.dim_background {
background-color: #222;
}

View File

@@ -175,19 +175,19 @@
</div>
{/if}
<div id="preload_font">.</div>
</div> <!-- div "game_page" -->
<!-- -->
<style>
@font-face {
#preload_font {
font-family: "Bit5x3";
src:
url("/fonts/Bit5x3.woff2") format("woff2"),
local("Bit5x3"),
url("/fonts/Bit5x3.woff") format("woff");
font-weight: normal;
font-style: normal;
font-display: swap;
opacity:0;
height:0;
width:0;
display:inline-block;
}
.dim_background {

View File

@@ -51,7 +51,7 @@
.then((response) => {
if (!response.ok) {
success.username = ''
errors.username = "Something went wrong";
errors.username = "Max length : 50 . Use [a-zA-Z0-9] and - _ .";
if (response.status === 409) {
errors.username = `${set.username} is already in use, pick a different one.`;
}
@@ -93,9 +93,11 @@
)
.then((response) => {
if (!response.ok) {
success.avatar = ''
errors.avatar = response.statusText;
throw new Error("HTTP " + response.status);
}
errors.avatar = ''
uploadAvatarSuccess = true;
success.avatar = 'Your avatar has been updated';
})
@@ -144,6 +146,7 @@
<div class="label">Pick a new Avatar</div>
<input type="file" bind:files={newAvatar}/>
<div class="error">{errors.avatar}</div>
<div class="success">{success.avatar}</div>
</div>
<Button type={!newAvatar ? "primary" : "secondary"}>Upload Avatar</Button>
</form>
@@ -189,6 +192,7 @@
.form-field {
padding: 10px;
color: #333;
}
.label {