|
|
|
@ -5,16 +5,19 @@ import android.util.Log
|
|
|
|
|
import com.example.what_the_fantasy.data.local.UserStub
|
|
|
|
|
import com.example.what_the_fantasy.data.local.UserStub.users
|
|
|
|
|
import com.example.what_the_fantasy.data.model.User
|
|
|
|
|
import com.example.what_the_fantasy.Logs.LogsUsers
|
|
|
|
|
import com.example.what_the_fantasy.ui.components.hashPassword
|
|
|
|
|
import java.time.LocalDate
|
|
|
|
|
|
|
|
|
|
class ServicesStub : IServices {
|
|
|
|
|
val logsUser = LogsUsers() //gestion des logs pour les utilisateurs
|
|
|
|
|
|
|
|
|
|
override fun EditUsername(username: String, index : Int) {
|
|
|
|
|
val user = getUserById(index)
|
|
|
|
|
user?.username = username
|
|
|
|
|
|
|
|
|
|
//Afficher tous les users
|
|
|
|
|
debugDisplayUser(getAllUsers(), "UsernameUpdate")
|
|
|
|
|
logsUser.logDebugDisplayUsers(getAllUsers(), "UsernameUpdate")
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -23,7 +26,7 @@ class ServicesStub : IServices {
|
|
|
|
|
user?.email = email
|
|
|
|
|
|
|
|
|
|
//Afficher tous les users
|
|
|
|
|
debugDisplayUser(getAllUsers(), "EmailUpdate")
|
|
|
|
|
logsUser.logDebugDisplayUsers(getAllUsers(), "EmailUpdate")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun EditPasswd(passwd: String,index : Int) {
|
|
|
|
@ -32,14 +35,14 @@ class ServicesStub : IServices {
|
|
|
|
|
user?.password = passwordhash
|
|
|
|
|
|
|
|
|
|
//Afficher tous les users en log
|
|
|
|
|
debugDisplayUser(getAllUsers(), "PasswordUpdate")
|
|
|
|
|
logsUser.logDebugDisplayUsers(getAllUsers(), "PasswordUpdate")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun EditImage(imageURL: String,index : Int) {
|
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun CreateUser(username: String, email: String, passwd: String, imageURL: String, services : IServices) : Boolean {
|
|
|
|
|
override fun CreateUser(username: String, email: String, passwd: String, services : IServices) : Boolean {
|
|
|
|
|
val date =dateDuJour()
|
|
|
|
|
val passwordhash = hashPassword(passwd)
|
|
|
|
|
|
|
|
|
@ -50,11 +53,11 @@ class ServicesStub : IServices {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val user = User(nbUser+1,username, email, imageURL, date, passwordhash)
|
|
|
|
|
val user = User(nbUser+1,username, email, date,randomImage(userStub), passwordhash)
|
|
|
|
|
users.add(user)//ajout au stub
|
|
|
|
|
|
|
|
|
|
//Afficher tous les users
|
|
|
|
|
debugDisplayUser(users, "CreateUser")
|
|
|
|
|
logsUser.logDebugDisplayUsers(users, "CreateUser")
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -80,10 +83,7 @@ class ServicesStub : IServices {
|
|
|
|
|
return date.toString()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun debugDisplayUser(users : List<User>, titleLog : String){
|
|
|
|
|
for(user in users){
|
|
|
|
|
Log.e(titleLog, "User created: ${user.username} => ${user.email} => ${user.password}")
|
|
|
|
|
}
|
|
|
|
|
fun randomImage(usersImage : List<User>) : String{
|
|
|
|
|
return "https://img.freepik.com/vecteurs-libre/personnage-guerrier-homme-fantaisie_1045-194.jpg?size=338&ext=jpg"
|
|
|
|
|
}
|
|
|
|
|
}
|