Files
2009scape/Server/src/main/kotlin/rs09/auth/DevelopmentAuthenticator.kt
T
Ceikry 9ab9885eef Introduced modular components for authentication, including the storage backend
Servers in dev mode now have a no-auth equivalent that allows any user/pass combo without registration
Added a ban command
Added a mute command
Hooked up the mute functionality of the report screen (for pmods+)
Cleaned up all the now-unused classes for player SQL stuff
Player SQL stuff now uses entirely prepared statements
No longer storing PC name, MAC address, serial number as these are inauthentic components of the protocol Packet to be corrected in the future to allow closer compatibility with authentic clients
Used less threading for the SQL queries/updates as these were causing issues both with the old system and the new
Updated ::resetpassword and ::setpasswordother commands to use the new server authentication pipeline (to ensure things are always correctly set)
Refactored the login read event, now handles more exceptions and edge cases
2022-05-16 11:51:42 +00:00

40 lines
1.3 KiB
Kotlin

package rs09.auth
import core.game.node.entity.player.Player
import rs09.storage.InMemoryStorageProvider
class DevelopmentAuthenticator : AuthProvider<InMemoryStorageProvider>() {
override fun configureFor(provider: InMemoryStorageProvider) {
storageProvider = provider
}
override fun checkLogin(username: String, password: String): Pair<AuthResponse, UserAccountInfo?> {
val info: UserAccountInfo
if(!storageProvider.checkUsernameTaken(username.toLowerCase())) {
info = UserAccountInfo.createDefault()
info.username = username
createAccountWith(info)
} else {
info = storageProvider.getAccountInfo(username.toLowerCase())
}
return Pair(AuthResponse.Success, storageProvider.getAccountInfo(username))
}
override fun createAccountWith(info: UserAccountInfo): Boolean {
info.username = info.username.toLowerCase()
info.rights = 2
storageProvider.store(info)
return true
}
override fun checkPassword(player: Player, password: String): Boolean {
return password == player.details.password
}
override fun updatePassword(username: String, newPassword: String) {
val info = storageProvider.getAccountInfo(username)
info.password = newPassword
storageProvider.update(info)
}
}