Skip to content

Commit

Permalink
Added invalid credentials check for OIDC
Browse files Browse the repository at this point in the history
  • Loading branch information
cocojoe committed Sep 7, 2017
1 parent a454345 commit f1bbaaa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 110 deletions.
108 changes: 0 additions & 108 deletions Auth0.xcodeproj/xcshareddata/xcschemes/OAuth2.iOS.xcscheme

This file was deleted.

2 changes: 1 addition & 1 deletion Auth0/AuthenticationError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public class AuthenticationError: Auth0Error, CustomStringConvertible {

/// When username and/or password used for authentication are invalid
public var isInvalidCredentials: Bool {
return self.code == "invalid_user_password"
return self.code == "invalid_user_password" || (self.code == "invalid_grant" && self.description == "Wrong email or password.")
}

/// When authenticating with web-based authentication and the resource server denied access per OAuth2 spec
Expand Down
10 changes: 9 additions & 1 deletion Auth0Tests/AuthenticationErrorSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ class AuthenticationErrorSpec: QuickSpec {
expect(error.isTooManyAttempts) == true
}

it("should detect invalid credentials") {
let values = [
"error": "invalid_grant",
"error_description": "Wrong email or password."
]
let error = AuthenticationError(info: values, statusCode: 403)
expect(error.isInvalidCredentials) == true
}

}

}
Expand Down Expand Up @@ -205,7 +214,6 @@ class AuthenticationErrorSpecSharedExamplesConfiguration: QuickConfiguration {
}
}


it("should not match any custom error") {
expect(error.isRuleError).to(beFalse(), description: "should not match rule error")
expect(error.isPasswordNotStrongEnough).to(beFalse(), description: "should not match pwd strength")
Expand Down

0 comments on commit f1bbaaa

Please sign in to comment.