mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Authorize share access
This commit is contained in:
@ -6,18 +6,29 @@
|
||||
|
||||
package docspell.common
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
import cats.effect.Sync
|
||||
import cats.implicits._
|
||||
|
||||
import io.circe.{Decoder, Encoder}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
final class Password(val pass: String) extends AnyVal {
|
||||
|
||||
def isEmpty: Boolean = pass.isEmpty
|
||||
def nonEmpty: Boolean = pass.nonEmpty
|
||||
def length: Int = pass.length
|
||||
|
||||
def asByteVector: ByteVector =
|
||||
ByteVector.view(pass.getBytes(StandardCharsets.UTF_8))
|
||||
|
||||
override def toString: String =
|
||||
if (pass.isEmpty) "<empty>" else "***"
|
||||
|
||||
def compare(other: Password): Boolean =
|
||||
this.pass.zip(other.pass).forall { case (a, b) => a == b } &&
|
||||
this.nonEmpty && this.length == other.length
|
||||
}
|
||||
|
||||
object Password {
|
||||
|
@ -70,6 +70,9 @@ object Timestamp {
|
||||
def atUtc(ldt: LocalDateTime): Timestamp =
|
||||
from(ldt.atZone(UTC))
|
||||
|
||||
def ofMillis(ms: Long): Timestamp =
|
||||
Timestamp(Instant.ofEpochMilli(ms))
|
||||
|
||||
def daysBetween(ts0: Timestamp, ts1: Timestamp): Long =
|
||||
ChronoUnit.DAYS.between(ts0.toUtcDate, ts1.toUtcDate)
|
||||
|
||||
|
Reference in New Issue
Block a user