summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--bank/src/main/kotlin/tech/libeufin/bank/Database.kt11
-rw-r--r--bank/src/main/kotlin/tech/libeufin/bank/Main.kt33
m---------contrib/wallet-core0
4 files changed, 45 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 7fd05bf0..da0b6874 100644
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,8 @@ deb: exec-arch copy-spa
.PHONY: install-bank
install-bank:
- @install -D contrib/libeufin-bank.conf $(config_dir)
+ install -d $(config_dir)
+ install contrib/libeufin-bank.conf $(config_dir)/
@./gradlew -q -Pprefix=$(prefix) bank:installToPrefix; cd ..
# To reactivate after the refactoring.
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Database.kt b/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
index 960b8d59..110f3a1e 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
@@ -241,6 +241,17 @@ class Database(private val dbConfig: String, private val bankCurrency: String) {
}
}
+ fun customerChangePassword(customerName: String, passwordHash: String): Boolean {
+ reconnect()
+ val stmt = prepare("""
+ UPDATE customers SET password_hash=? where login=?
+ """)
+ stmt.setString(1, passwordHash)
+ stmt.setString(2, customerName)
+ stmt.executeUpdate()
+ return stmt.updateCount > 0
+ }
+
fun customerGetFromLogin(login: String): Customer? {
reconnect()
val stmt = prepare("""
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
index 5d391191..09da3cd8 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
@@ -27,6 +27,7 @@ import com.github.ajalt.clikt.parameters.options.*
import com.github.ajalt.clikt.core.context
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.output.CliktHelpFormatter
+import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.options.versionOption
import io.ktor.http.*
import io.ktor.server.application.*
@@ -294,7 +295,7 @@ fun Application.corebankWebApp(db: Database, ctx: BankApplicationContext) {
class LibeufinBankCommand : CliktCommand() {
init {
versionOption(getVersion())
- subcommands(ServeBank(), BankDbInit())
+ subcommands(ServeBank(), BankDbInit(), ChangePw())
}
override fun run() = Unit
@@ -449,6 +450,36 @@ class ServeBank : CliktCommand("Run libeufin-bank HTTP server", name = "serve")
}
}
+class ChangePw : CliktCommand("Change account password", name = "passwd") {
+ private val configFile by option(
+ "--config", "-c",
+ help = "set the configuration file"
+ )
+ private val account by argument("account")
+ private val password by argument("password")
+ init {
+ context {
+ helpFormatter = CliktHelpFormatter(showDefaultValues = true)
+ }
+ }
+
+ override fun run() {
+ val config = TalerConfig.load(this.configFile)
+ val ctx = readBankApplicationContextFromConfig(config)
+ val dbConnStr = config.requireValueString("libeufin-bankdb-postgres", "config")
+ val servePortLong = config.requireValueNumber("libeufin-bank", "port")
+ val db = Database(dbConnStr, ctx.currency)
+ if (!maybeCreateAdminAccount(db, ctx)) // logs provided by the helper
+ exitProcess(1)
+
+ if (!db.customerChangePassword(account, CryptoUtil.hashpw(password))) {
+ println("password change failed")
+ } else {
+ println("password change succeeded")
+ }
+ }
+}
+
fun main(args: Array<String>) {
LibeufinBankCommand().main(args)
}
diff --git a/contrib/wallet-core b/contrib/wallet-core
-Subproject c5a3cd4c50676c49fa6c67cbdeb609101c38e76
+Subproject 9e2d95b39723a038eb714d723ac0910a5bf596e