Initial impl for totp

This commit is contained in:
eikek
2021-08-30 16:15:13 +02:00
parent 2b46cc7970
commit 309a52393a
17 changed files with 568 additions and 20 deletions

View File

@ -9,13 +9,13 @@ package docspell.common
import io.circe._
case class AccountId(collective: Ident, user: Ident) {
def asString =
s"${collective.id}/${user.id}"
if (collective == user) user.id
else s"${collective.id}/${user.id}"
}
object AccountId {
private[this] val sepearatorChars: String = "/\\:"
private[this] val separatorChars: String = "/\\:"
def parse(str: String): Either[String, AccountId] = {
val input = str.replaceAll("\\s+", "").trim
@ -36,7 +36,7 @@ object AccountId {
invalid
}
val separated = sepearatorChars.foldRight(invalid)((c, v) => v.orElse(parse0(c)))
val separated = separatorChars.foldRight(invalid)((c, v) => v.orElse(parse0(c)))
separated.orElse(Ident.fromString(str).map(id => AccountId(id, id)))
}