Merge remote-tracking branch 'origin/master' into eric_front_and_back
This commit is contained in:
@@ -12,17 +12,8 @@ import { SessionSerializer } from './utils/serializer';
|
|||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([User, Friendship]), UsersModule,
|
imports: [TypeOrmModule.forFeature([User, Friendship]), UsersModule,
|
||||||
// JwtModule.registerAsync({
|
|
||||||
// useFactory: async (configService: ConfigService) => {
|
|
||||||
// return {
|
|
||||||
// signOptions: { expiresIn: '1h' },
|
|
||||||
// secret: process.env.JWT_SECRET,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
],
|
],
|
||||||
providers: [AuthenticationService, FortyTwoStrategy, UsersService, SessionSerializer, FriendshipService
|
providers: [AuthenticationService, FortyTwoStrategy, UsersService, SessionSerializer, FriendshipService
|
||||||
// JwtStrategy
|
|
||||||
],
|
],
|
||||||
exports: [AuthenticationService],
|
exports: [AuthenticationService],
|
||||||
controllers: [AuthenticationController],
|
controllers: [AuthenticationController],
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export class User {
|
|||||||
@Column({unique: true})
|
@Column({unique: true})
|
||||||
fortyTwoId: string;
|
fortyTwoId: string;
|
||||||
|
|
||||||
@Column()
|
@Column({unique: true})
|
||||||
username: string;
|
username: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export class UsersController {
|
|||||||
@Patch()
|
@Patch()
|
||||||
async update(@Req() req, @Body(new ValidationPipe()) usersUpdateDto: UpdateUsersDto, @Res() response : Response) {
|
async update(@Req() req, @Body(new ValidationPipe()) usersUpdateDto: UpdateUsersDto, @Res() response : Response) {
|
||||||
console.log('user.controller updating user info')
|
console.log('user.controller updating user info')
|
||||||
const user = await this.usersService.update(req.user.id, usersUpdateDto);
|
const user = await this.usersService.update(req.user.id, usersUpdateDto, req.user.username);
|
||||||
if (user.isEnabledTwoFactorAuth === false && user.isTwoFactorAuthenticated === true)
|
if (user.isEnabledTwoFactorAuth === false && user.isTwoFactorAuthenticated === true)
|
||||||
this.usersService.setIsTwoFactorAuthenticatedWhenLogout(user.id);
|
this.usersService.setIsTwoFactorAuthenticatedWhenLogout(user.id);
|
||||||
if (user.isEnabledTwoFactorAuth === true && user.isTwoFactorAuthenticated === false)
|
if (user.isEnabledTwoFactorAuth === true && user.isTwoFactorAuthenticated === false)
|
||||||
|
|||||||
@@ -55,12 +55,9 @@ export class UsersService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async isUsernameExists(usernameToSearch: string): Promise<boolean> {
|
async isUsernameExists(usernameToSearch: string): Promise<boolean> {
|
||||||
// console.log('searching for username: ' + usernameToSearch)
|
const user = await this.userRepository.createQueryBuilder('user')
|
||||||
|
.where('LOWER(user.username) = LOWER(:username)', {username : usernameToSearch})
|
||||||
const user = await this.userRepository.findOneBy({username : usernameToSearch});
|
.getOne()
|
||||||
|
|
||||||
// console.log({...user})
|
|
||||||
|
|
||||||
if (!user)
|
if (!user)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
@@ -101,10 +98,9 @@ export class UsersService {
|
|||||||
return this.userRepository.save(user);
|
return this.userRepository.save(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(id: number, updateUserDto: UpdateUsersDto) {
|
async update(id: number, updateUserDto: UpdateUsersDto, username : string) {
|
||||||
// console.log(`Update user ${id} with ${updateUserDto.isEnabledTwoFactorAuth}`);
|
console.log("Maj user username : " + username + " updateuser dto " + updateUserDto.username )
|
||||||
// console.log({...updateUserDto})
|
if (await this.isUsernameExists(updateUserDto.username) === true && updateUserDto.username !== username) {
|
||||||
if (await this.isUsernameExists(updateUserDto.username) === true) {
|
|
||||||
// console.log('updating username ' + updateUserDto.username + ' but it already is in use')
|
// console.log('updating username ' + updateUserDto.username + ' but it already is in use')
|
||||||
throw new HttpException(`The username is already in use.`,HttpStatus.CONFLICT);
|
throw new HttpException(`The username is already in use.`,HttpStatus.CONFLICT);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -16,11 +16,11 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "Bit5x3";
|
font-family: "PressStart2P";
|
||||||
src:
|
src:
|
||||||
url("./fonts/Bit5x3.woff2") format("woff2"),
|
url("./fonts/PressStart2P.woff2") format("woff2"),
|
||||||
local("Bit5x3"),
|
local("PressStart2P"),
|
||||||
url("./fonts/Bit5x3.woff") format("woff");
|
url("./fonts/PressStart2P.woff") format("woff");
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
@@ -42,8 +42,8 @@ a:visited {
|
|||||||
|
|
||||||
.background-pages {
|
.background-pages {
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
font-family: "Bit5x3";
|
font-family: "PressStart2P";
|
||||||
font-size: 2vw;
|
font-size: 1vw;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,8 +77,8 @@
|
|||||||
border-color: #071013;
|
border-color: #071013;
|
||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: "Bit5x3";
|
font-family: "PressStart2P";
|
||||||
font-size: x-large;
|
font-size: 1vw;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +87,8 @@
|
|||||||
border-color: #071013;
|
border-color: #071013;
|
||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: "Bit5x3";
|
font-family: "PressStart2P";
|
||||||
font-size: x-large;
|
font-size: 1vw;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
|
|
||||||
.error {
|
.error {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 0.8em;
|
font-size: 1vw;
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -393,7 +393,16 @@
|
|||||||
</div> <!-- div "game_page" -->
|
</div> <!-- div "game_page" -->
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@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;
|
||||||
|
}
|
||||||
.dim_background {
|
.dim_background {
|
||||||
background-color: #222;
|
background-color: #222;
|
||||||
}
|
}
|
||||||
@@ -423,15 +432,16 @@ canvas {
|
|||||||
/* background-color: #ff0000; */
|
/* background-color: #ff0000; */
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
max-width: 75vw;
|
max-width: 75vw;
|
||||||
|
font-family: "Bit5x3";
|
||||||
/* max-height: 100vh; */
|
/* max-height: 100vh; */
|
||||||
width: 80%;
|
width: 80%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.div_game {
|
.div_game {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-family: "Bit5x3";
|
font-family: "PressStart2P";
|
||||||
color: rgb(245, 245, 245);
|
color: rgb(245, 245, 245);
|
||||||
font-size: x-large;
|
font-size: 1vw;
|
||||||
}
|
}
|
||||||
.div_game fieldset {
|
.div_game fieldset {
|
||||||
max-width: 50vw;
|
max-width: 50vw;
|
||||||
@@ -442,10 +452,10 @@ canvas {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
.pong_button {
|
.pong_button {
|
||||||
font-family: "Bit5x3";
|
font-family: "PressStart2P";
|
||||||
color: rgb(245, 245, 245);
|
color: rgb(245, 245, 245);
|
||||||
background-color: #333333;
|
background-color: #333333;
|
||||||
font-size: x-large;
|
font-size: 1vw;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
.avatar {
|
.avatar {
|
||||||
|
|||||||
@@ -179,6 +179,16 @@
|
|||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<style>
|
<style>
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
.dim_background {
|
.dim_background {
|
||||||
background-color: #222;
|
background-color: #222;
|
||||||
@@ -203,15 +213,16 @@ canvas {
|
|||||||
/* background-color: #ff0000; */
|
/* background-color: #ff0000; */
|
||||||
background-color: #333333;
|
background-color: #333333;
|
||||||
max-width: 75vw;
|
max-width: 75vw;
|
||||||
|
font-family: "Bit5x3";
|
||||||
/* max-height: 100vh; */
|
/* max-height: 100vh; */
|
||||||
width: 80%;
|
width: 80%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.div_game {
|
.div_game {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-family: "Bit5x3";
|
font-family: "PressStart2P";
|
||||||
color: rgb(245, 245, 245);
|
color: rgb(245, 245, 245);
|
||||||
font-size: x-large;
|
font-size: 1vw;
|
||||||
}
|
}
|
||||||
.div_game fieldset {
|
.div_game fieldset {
|
||||||
max-width: 50vw;
|
max-width: 50vw;
|
||||||
@@ -222,15 +233,15 @@ canvas {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
.pong_button {
|
.pong_button {
|
||||||
font-family: "Bit5x3";
|
font-family: "PressStart2P";
|
||||||
color: rgb(245, 245, 245);
|
color: rgb(245, 245, 245);
|
||||||
background-color: #333333;
|
background-color: #333333;
|
||||||
font-size: x-large;
|
font-size: 1vw;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
#match_list {
|
#match_list {
|
||||||
font-family: 'Courier New', Courier, monospace;
|
font-family: 'Courier New', Courier, monospace;
|
||||||
font-size: large;
|
font-size: 1vw;
|
||||||
}
|
}
|
||||||
.avatar {
|
.avatar {
|
||||||
min-height: 100px;
|
min-height: 100px;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
.stats-table {
|
.stats-table {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
font-size: 0.9em;
|
font-size: 1vw;
|
||||||
min-width: 400px;
|
min-width: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +91,9 @@
|
|||||||
.stats-table th,
|
.stats-table th,
|
||||||
.stats-table td {
|
.stats-table td {
|
||||||
padding: 12px 15px;
|
padding: 12px 15px;
|
||||||
|
size: 10vw;
|
||||||
|
max-width: 10vw;
|
||||||
|
overflow-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats-table tbody tr {
|
.stats-table tbody tr {
|
||||||
|
|||||||
@@ -32,20 +32,10 @@
|
|||||||
|
|
||||||
const settingsHandler = async() =>
|
const settingsHandler = async() =>
|
||||||
{
|
{
|
||||||
// TODO Luke <--> Eric : Explications
|
if ((set.username.trim() === '')) {
|
||||||
// I don't really care which i use at this point...
|
|
||||||
// if (set.username === nameTmp) {
|
|
||||||
if ((set.username.trim() === '') && set.tfa === user.isEnabledTwoFactorAuth) {
|
|
||||||
errors.username = 'Invalid new username';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if ((set.username.trim() === '') && set.tfa !== user.isEnabledTwoFactorAuth) {
|
|
||||||
set.username = user.username
|
set.username = user.username
|
||||||
}
|
}
|
||||||
else {
|
errors.username = ''
|
||||||
errors.username = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user`,
|
await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user`,
|
||||||
{
|
{
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
@@ -60,6 +50,7 @@
|
|||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
success.username = ''
|
||||||
errors.username = "Something went wrong";
|
errors.username = "Something went wrong";
|
||||||
if (response.status === 409) {
|
if (response.status === 409) {
|
||||||
errors.username = `${set.username} is already in use, pick a different one.`;
|
errors.username = `${set.username} is already in use, pick a different one.`;
|
||||||
@@ -68,6 +59,7 @@
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
|
errors.username = ''
|
||||||
success.username = "Your changes have been saved";
|
success.username = "Your changes have been saved";
|
||||||
}
|
}
|
||||||
else if (response.status === 201) {
|
else if (response.status === 201) {
|
||||||
@@ -210,13 +202,13 @@
|
|||||||
|
|
||||||
|
|
||||||
.error{
|
.error{
|
||||||
font-size: 0.8em;
|
font-size: 1vw;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.success{
|
.success{
|
||||||
font-size: 0.8em;
|
font-size: 1vw;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: green;
|
color: green;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -430,7 +430,7 @@
|
|||||||
|
|
||||||
div.top-grid{
|
div.top-grid{
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(12, 1fr);
|
grid-template-columns: repeat(8, 1fr);
|
||||||
/* max-height: calc(100vh - 30vh); */
|
/* max-height: calc(100vh - 30vh); */
|
||||||
height: 85vh;
|
height: 85vh;
|
||||||
/* margin: 0; */
|
/* margin: 0; */
|
||||||
@@ -440,12 +440,15 @@
|
|||||||
grid-column: 1 / span 2;
|
grid-column: 1 / span 2;
|
||||||
background: #FB8B24;
|
background: #FB8B24;
|
||||||
padding: 1vw;
|
padding: 1vw;
|
||||||
|
font-size: smaller;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
-moz-box-sizing: border-box;
|
-moz-box-sizing: border-box;
|
||||||
-webkit-box-sizing: border-box;
|
-webkit-box-sizing: border-box;
|
||||||
border-right: 4px solid #071013;
|
border-right: 4px solid #071013;
|
||||||
|
border-bottom: 4px solid #071013;
|
||||||
|
overflow-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.sidebar-item{
|
div.sidebar-item{
|
||||||
|
|||||||
@@ -153,7 +153,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.error{
|
.error{
|
||||||
font-size: 0.8em;
|
font-size: 1vw;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,9 +54,9 @@
|
|||||||
background-color: #444;
|
background-color: #444;
|
||||||
border-color: #071013;
|
border-color: #071013;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: "Bit5x3";
|
font-family: "PressStart2P";
|
||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
font-size: 2vw;
|
font-size: 1vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -64,9 +64,9 @@
|
|||||||
background-color: #008c8c;
|
background-color: #008c8c;
|
||||||
border-color: #071013;
|
border-color: #071013;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: "Bit5x3";
|
font-family: "PressStart2P";
|
||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
font-size: 2vw;
|
font-size: 1vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
|
|||||||
Reference in New Issue
Block a user