Merge branch 'tibor' into 'master'

authenticaction, registration, login fix

See merge request bossanyit/aitrainer_server!2
This commit is contained in:
Bossányi Tibor 2020-06-10 15:28:02 +00:00
commit e3e02a5bef
5 changed files with 12 additions and 20 deletions

View File

@ -1 +1,2 @@
INSERT INTO `customer` (`name`, `firstname`, `email`, `password`, `sex`, `age`, `active`, `date_add`, `date_change`, `data_policy_allowed`, `admin`) VALUES ('Dummy User', NULL, 'bosi', '$2a$10$thOc8jS750c7xe9U9Qq3GuSPs/H0Pt2Ads05yzUlyzQBIj.Rk9QCy', 'm', 40, 'N', NULL, NULL, 1, 1);
UPDATE configuration set config_value = "0.0.3" WHERE config_key = "db_version";

View File

@ -23,9 +23,15 @@ class AuthenticationControllerAspect {
private lateinit var properties: ApplicationProperties
@Before("execution(* com.aitrainer.api.security.JwtAuthenticationController.*(..))")
fun customerControllerAspect(joinPoint: JoinPoint) {
fun authControllerAspect(joinPoint: JoinPoint) {
println("auth controller join")
Singleton.checkDBUpdate(configurationRepository, properties)
}
@Before("execution(* com.aitrainer.api.security.JwtSecurityConfig.*(..))")
fun securityControllerAspect(joinPoint: JoinPoint) {
println("JwtSecurity config join")
Singleton.checkDBUpdate(configurationRepository, properties)
}
}

View File

@ -40,10 +40,14 @@ class JwtAuthenticationController {
private fun authenticate(username: String, password: String) {
try {
authenticationManager!!.authenticate(UsernamePasswordAuthenticationToken(username, password))
println("authenticating....")
} catch (e: DisabledException) {
throw Exception("USER_DISABLED", e)
} catch (e: BadCredentialsException) {
throw Exception("INVALID_CREDENTIALS", e)
} catch( e: Exception) {
println("Auth exception " + e.message)
throw Exception("Other Exception", e)
}
}
}

View File

@ -15,17 +15,4 @@ class ConfigurationTest {
private lateinit var configurationRepository: ConfigurationRepository
private lateinit var configurationController: ConfigurationController
@Test
fun testUpdateConfig() {
val config: Configuration = configurationRepository.findByConfigKey("db_version")
config.configValue = "0.0.2"
configurationController = ConfigurationController(configurationRepository)
val updatedConfig: Configuration = configurationController.updateConfiguration(config)
assertEquals(updatedConfig.configValue, "0.0.2")
val foundConfig: Configuration = configurationRepository.findByConfigKey("db_version")
assertEquals(foundConfig.configValue, "0.0.2")
}
}

View File

@ -12,12 +12,6 @@ class PropertiesTest {
@Autowired
private lateinit var properties: ApplicationProperties
@Test
fun testProperties() {
val version: String = properties.getVersion()
assertEquals(version, "0.0.2")
}
@Test
fun testDatasourceUrl() {
val url: String = properties.getDatasourceUrl()