quitter match marche + tentative hashage
continuous-integration/drone/push Build is passing Details

peristanceBDD
Thomas Chazot 2 years ago
parent 1acc475741
commit b5ecdb455b

@ -110,12 +110,16 @@ class UserGateway{
public function getUserForConnection(string $username,string $password):?User{
$userQuery = "SELECT *
FROM T_S_USER_USR
WHERE USR_USERNAME=:username
AND USR_PASSWORD=:password";
WHERE USR_USERNAME=:username";
$argUsernamePassword=(array('username'=>array($username,PDO::PARAM_STR),
'password'=>array($password,PDO::PARAM_STR)));
$this->connection->execQuery($userQuery,$argUsernamePassword);
$res=$this->connection->getRes();
foreach($res as $row){
if(!password_verify($password,$row["USR_USERNAME"])){
return null;
}
}
$usr=$this->convertResToUser($res);
if ($usr != null){
$usr->tabSkin=$this->getSkinList($usr->id);
@ -127,6 +131,7 @@ class UserGateway{
/// Parameters : * $u (User): user we want to insert in database
/// Returning TRUE if the user has been added succesfully, FALSE otherwise
public function postUser(string $username, string $password, string $nationality, string $sex, string $dateOfBirth) {
$password=password_hash($password,PASSWORD_DEFAULT);
$insertUserQuery = "INSERT INTO T_S_USER_USR VALUES (NULL, :username, :password, :nationality, :sex, :dateOfBirth, 0, 0, 0, 1)";
$getLastIdQuery = "SELECT max(PK_ID) id FROM T_S_USER_USR";
$argUser=array('username' => array($username, PDO::PARAM_STR),
@ -146,6 +151,7 @@ class UserGateway{
/// Parameters : * $u (User): user we want to update in database
/// Returning TRUE if the modifications has been done succesfully, FALSE otherwise
public function putUser(int $id,string $username, string $password, string $sex, string $nationality, int $currentBobCoins,int $totalBobCoins,int $nbGamesPlayed, int $currentSkin){
$password=password_hash($password,PASSWORD_DEFAULT);
$updateUserQuery="UPDATE T_S_USER_USR
SET USR_USERNAME = :username,
USR_PASSWORD=:password,

@ -10,7 +10,7 @@ export default class MatchMulti extends Match{
super(code, inGame, tabUser, game);
}
async updatePostMatch(user:User, points: number): void {
async updatePostMatch(user:User, points: number): Promise<void> {
const manage= new UserCoinsModifier();
await manage.addCoins(user, this.getGame().coinsCalculator(points));
}

@ -10,7 +10,7 @@ export default class MatchSolo extends Match{
super(code, inGame, tabUser, game);
}
async updatePostMatch(user:User, points: number): void {
async updatePostMatch(user:User, points: number): Promise<void> {
const manage= new UserCoinsModifier();
await manage.addCoins(user, this.getGame().coinsCalculator(points));
}

@ -44,7 +44,7 @@ export default class SaverMatchApi implements ISaverMatch{
}
async deleteUserFromMatch(u: User): Promise<void> {
let url=this.baseUrl + 'deleteUserFromMatch.php/' + u.id;
let url=this.baseUrl + 'deleteUserFromMatch/' + u.id;
await this.axios({
method: 'put',
url: url,
@ -61,7 +61,8 @@ export default class SaverMatchApi implements ISaverMatch{
await MANAGER_MATCH.getLoaderMatch().loadByID(id).then(async (response)=>{
if (response!==undefined && response !== null){
if (response.getTabUsers().length<response.getGame().getNbPlayerMax() || response.getInGame()===false){
console.log(response.getTabUsers().length + " : " + response.getGame().getNbPlayerMax());
if (response.getTabUsers().length<response.getGame().getNbPlayerMax() && response.getInGame()===false){
response.getTabUsers().push(u);
match=response;
await this.axios({

Loading…
Cancel
Save