Remove code smell
continuous-integration/drone/push Build was killed Details

pull/4/head
luevard 1 year ago
parent a49474b525
commit 262b7ed9a0

@ -6,7 +6,6 @@ import allin.model.User
import allin.utils.Execute
import org.ktorm.dsl.*
import org.ktorm.entity.*
import org.ktorm.expression.SqlExpression
import org.ktorm.schema.Table
import org.ktorm.schema.double
import org.ktorm.schema.int

@ -1,8 +1,6 @@
package allin.routing
import allin.model.BetAction
import io.ktor.server.application.*
import io.ktor.server.request.*
import io.ktor.server.routing.*
fun Application.BetActionRouter(){

@ -43,7 +43,7 @@ fun Application.ParticipationRouter() {
hasToken { principal ->
val participationId = call.receive<String>()
participations.find { it.id == participationId }?.let { participation ->
verifyUserFromToken(principal) { user, _ ->
verifyUserFromToken(principal) { _, _ ->
// user.nbCoins += participation.stake
participations.remove(participation)
call.respond(HttpStatusCode.NoContent)

@ -17,7 +17,6 @@ import io.ktor.server.auth.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import org.ktorm.database.Database
import java.util.*
val RegexCheckerUser = AppConfig.regexChecker
@ -34,7 +33,7 @@ fun Application.UserRouter() {
call.respond(HttpStatusCode.Forbidden, ApiMessage.InvalidMail)
}
val users = getUserToUserDTO()
users.find { it.username == tempUser.username || it.email == tempUser.email }?.let { user ->
users.find { it.username == tempUser.username || it.email == tempUser.email }?.let { _ ->
call.respond(HttpStatusCode.Conflict, ApiMessage.UserAlreadyExist)
} ?: run {
val user = User(

@ -4,15 +4,15 @@ import allin.model.User
import org.mindrot.jbcrypt.BCrypt
class CryptManager {
//val salt=BCrypt.gensalt()
val salt=System.getenv().get("SALT")
fun passwordCrypt(password : String): String {
return BCrypt.hashpw(password,"\$2a\$10\$42wsdBeoLKaF6SM9oADONe")
return BCrypt.hashpw(password,salt)
}
fun passwordCrypt(user: User){
user.password=BCrypt.hashpw(user.password,"\$2a\$10\$42wsdBeoLKaF6SM9oADONe")
user.password=BCrypt.hashpw(user.password,salt)
}
fun passwordDecrypt(password: String, passwordClear: String): Boolean{
return BCrypt.hashpw(passwordClear,"\$2a\$10\$42wsdBeoLKaF6SM9oADONe")==password
return BCrypt.hashpw(passwordClear,salt)==password
}
fun CheckPassword(hashed: String, clear: String): Boolean{

Loading…
Cancel
Save