|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.example.what_the_fantasy.ui.screens
|
|
|
|
|
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
@ -45,7 +46,7 @@ import com.example.what_the_fantasy.ui.theme.gradienBox
|
|
|
|
|
import java.security.MessageDigest
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: () -> Unit) {
|
|
|
|
|
fun LoginPage(navControllerSignUp: () -> Unit, navControllerProfil: (Int) -> Unit) {
|
|
|
|
|
|
|
|
|
|
val users = UserStub.allUsers;
|
|
|
|
|
|
|
|
|
@ -126,7 +127,7 @@ fun PassWdTextField(textpasswdResId : Int) : String{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun ConnexionButtonLogin(userStub : List<User>, id : String, passwd : String, titleResId : Int, size : Int, colorButton : Color, colorText : Color, navController: () -> Unit){
|
|
|
|
|
fun ConnexionButtonLogin(userStub : List<User>, id : String, passwd : String, titleResId : Int, size : Int, colorButton : Color, colorText : Color, navController: (Int) -> Unit){
|
|
|
|
|
val title = stringResource(id = titleResId)
|
|
|
|
|
Button(
|
|
|
|
|
onClick = { validLogin(id, passwd, userStub, navController) },
|
|
|
|
@ -139,12 +140,12 @@ fun ConnexionButtonLogin(userStub : List<User>, id : String, passwd : String, ti
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun validLogin(identifiant : String, passwd : String, users : List<User>, navController: () -> Unit){
|
|
|
|
|
users.forEach { user ->
|
|
|
|
|
fun validLogin(identifiant : String, passwd : String, users : List<User>, navController: (Int) -> Unit){
|
|
|
|
|
users.forEachIndexed { index, user ->
|
|
|
|
|
val hashPassWd = hashPassword(passwd)
|
|
|
|
|
|
|
|
|
|
if (user.username == identifiant && user.password == hashPassWd) run {
|
|
|
|
|
navController()
|
|
|
|
|
if (user.username == identifiant && user.password == hashPassWd) {
|
|
|
|
|
// Utilise l'index pour naviguer à la position correspondante
|
|
|
|
|
navController(index) // Passer l'index à la fonction navController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|