Skip to content

Commit

Permalink
taking into account non ascii characters as invalid username error
Browse files Browse the repository at this point in the history
  • Loading branch information
ouchadam committed Aug 4, 2022
1 parent bfd9dcb commit 825ba77
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ fun Throwable.isUsernameInUse() = this is Failure.ServerError &&
error.code == MatrixError.M_USER_IN_USE

fun Throwable.isInvalidUsername() = this is Failure.ServerError &&
error.code == MatrixError.M_INVALID_USERNAME
(error.code == MatrixError.M_INVALID_USERNAME || usernameContainsNonAsciiCharacters())

private fun Failure.ServerError.usernameContainsNonAsciiCharacters() = error.code == MatrixError.M_UNKNOWN &&
error.message == "Query parameter \'username\' must be ascii"

fun Throwable.isInvalidPassword() = this is Failure.ServerError &&
error.code == MatrixError.M_FORBIDDEN &&
Expand Down

0 comments on commit 825ba77

Please sign in to comment.