From 41a789b3f877652ffeb92ad023777b780db0fda5 Mon Sep 17 00:00:00 2001 From: Corey Baker Date: Sun, 22 Jan 2023 09:36:19 -0500 Subject: [PATCH 1/4] feat: Add user login related attempts to ParseCloudUser --- CHANGELOG.md | 1 + README.md | 3 +++ Sources/ParseSwift/Objects/ParseCloudUser.swift | 5 +++++ .../ParseHookFunctionRequestCombineTests.swift | 6 +++++- Tests/ParseSwiftTests/ParseHookFunctionRequestTests.swift | 4 ++++ .../ParseHookTriggerRequestCombineTests.swift | 4 ++++ Tests/ParseSwiftTests/ParseHookTriggerRequestTests.swift | 4 ++++ 7 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc3628f68..3a0c8060f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ deprecation warnings when building your app in Xcode before upgrading to [Corey Baker](https://github.com/cbaker6). __New features__ +* Add user login related attempts to ParseCloudUser. This allows developers to decode login related information when using Parse-Swift for Cloud Code ([#51](https://github.com/netreconlab/Parse-Swift/pull/51)), thanks to [Corey Baker](https://github.com/cbaker6). * Add option to set the serverURL for a particular call. This is useful when using the Swift SDK for Cloud Code in a multi-server environment ([#50](https://github.com/netreconlab/Parse-Swift/pull/50)), thanks to [Corey Baker](https://github.com/cbaker6). * ParseVersion now supports pre-release versions of the SDK ([#49](https://github.com/netreconlab/Parse-Swift/pull/49)), thanks to [Corey Baker](https://github.com/cbaker6). * Adds the the ability to watch particular keys with LiveQueries. Requires Parse-Server 6.0.0 ([#48](https://github.com/netreconlab/Parse-Swift/pull/48)), thanks to [Corey Baker](https://github.com/cbaker6). diff --git a/README.md b/README.md index d45d9e913..31cdd4d2d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ --- +[![Documentation](http://img.shields.io/badge/read_the-docs-2196f3.svg)](https://swiftpackageindex.com/netreconlab/Parse-Swift/documentation) +[![Playgrounds](http://img.shields.io/badge/read_the-playgrounds-2196f3.svg)](https://github.com/netreconlab/Parse-Swift/tree/main/ParseSwift.playground/Pages) +[![Tuturiol](http://img.shields.io/badge/read_the-tuturials-2196f3.svg)](https://netreconlab.github.io/Parse-Swift/release/tutorials/parseswift/) [![Build Status CI](https://github.com/netreconlab/Parse-Swift/workflows/ci/badge.svg?branch=main)](https://github.com/netreconlab/Parse-Swift/actions?query=workflow%3Aci+branch%3Amain) [![Build Status Release](https://github.com/netreconlab/Parse-Swift/workflows/release/badge.svg)](https://github.com/netreconlab/Parse-Swift/actions?query=workflow%3Arelease) [![Coverage](https://codecov.io/gh/netreconlab/Parse-Swift/branch/main/graph/badge.svg)](https://codecov.io/gh/netreconlab/Parse-Swift/branches) diff --git a/Sources/ParseSwift/Objects/ParseCloudUser.swift b/Sources/ParseSwift/Objects/ParseCloudUser.swift index a611f3f62..90491e639 100644 --- a/Sources/ParseSwift/Objects/ParseCloudUser.swift +++ b/Sources/ParseSwift/Objects/ParseCloudUser.swift @@ -15,4 +15,9 @@ import Foundation public protocol ParseCloudUser: ParseUser { /// The session token of the `ParseUser`. var sessionToken: String? { get set } + /// The number of unsuccessful login attempts. + var _failed_login_count: Int? { get } + /// The date the lockout expires. After this date, the `ParseUser` + /// can attempt to login again. + var _account_lockout_expires_at: Date? { get } } diff --git a/Tests/ParseSwiftTests/ParseHookFunctionRequestCombineTests.swift b/Tests/ParseSwiftTests/ParseHookFunctionRequestCombineTests.swift index 5df6356ef..d47fed1f1 100644 --- a/Tests/ParseSwiftTests/ParseHookFunctionRequestCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseHookFunctionRequestCombineTests.swift @@ -33,8 +33,12 @@ class ParseHookFunctionRequestCombineTests: XCTestCase { var emailVerified: Bool? var password: String? var authData: [String: [String: String]?]? + + // These are required by ParseCloudUser var sessionToken: String? - + var _failed_login_count: Int? + var _account_lockout_expires_at: Date? + // Your custom keys var customKey: String? diff --git a/Tests/ParseSwiftTests/ParseHookFunctionRequestTests.swift b/Tests/ParseSwiftTests/ParseHookFunctionRequestTests.swift index 64debe842..51f1a6701 100644 --- a/Tests/ParseSwiftTests/ParseHookFunctionRequestTests.swift +++ b/Tests/ParseSwiftTests/ParseHookFunctionRequestTests.swift @@ -35,7 +35,11 @@ class ParseHookFunctionRequestTests: XCTestCase { var emailVerified: Bool? var password: String? var authData: [String: [String: String]?]? + + // These are required by ParseCloudUser var sessionToken: String? + var _failed_login_count: Int? + var _account_lockout_expires_at: Date? // Your custom keys var customKey: String? diff --git a/Tests/ParseSwiftTests/ParseHookTriggerRequestCombineTests.swift b/Tests/ParseSwiftTests/ParseHookTriggerRequestCombineTests.swift index fc9cdf70f..b48f62aee 100644 --- a/Tests/ParseSwiftTests/ParseHookTriggerRequestCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseHookTriggerRequestCombineTests.swift @@ -30,7 +30,11 @@ class ParseHookTriggerRequestCombineTests: XCTestCase { var emailVerified: Bool? var password: String? var authData: [String: [String: String]?]? + + // These are required by ParseCloudUser var sessionToken: String? + var _failed_login_count: Int? + var _account_lockout_expires_at: Date? // Your custom keys var customKey: String? diff --git a/Tests/ParseSwiftTests/ParseHookTriggerRequestTests.swift b/Tests/ParseSwiftTests/ParseHookTriggerRequestTests.swift index 2f22f7ee8..fce738a07 100644 --- a/Tests/ParseSwiftTests/ParseHookTriggerRequestTests.swift +++ b/Tests/ParseSwiftTests/ParseHookTriggerRequestTests.swift @@ -31,7 +31,11 @@ class ParseHookTriggerRequestTests: XCTestCase { var emailVerified: Bool? var password: String? var authData: [String: [String: String]?]? + + // These are required by ParseCloudUser var sessionToken: String? + var _failed_login_count: Int? + var _account_lockout_expires_at: Date? // Your custom keys var customKey: String? From 10095ba988196f84e68eda8b2a1977dfceb21fb9 Mon Sep 17 00:00:00 2001 From: Corey Date: Sun, 22 Jan 2023 09:48:25 -0500 Subject: [PATCH 2/4] add doc badges --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 31cdd4d2d..14525b1ad 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,13 @@ --- [![Documentation](http://img.shields.io/badge/read_the-docs-2196f3.svg)](https://swiftpackageindex.com/netreconlab/Parse-Swift/documentation) -[![Playgrounds](http://img.shields.io/badge/read_the-playgrounds-2196f3.svg)](https://github.com/netreconlab/Parse-Swift/tree/main/ParseSwift.playground/Pages) +[![Playgrounds](http://img.shields.io/badge/swift-playgrounds-2196f3.svg)](https://github.com/netreconlab/Parse-Swift/tree/main/ParseSwift.playground/Pages) [![Tuturiol](http://img.shields.io/badge/read_the-tuturials-2196f3.svg)](https://netreconlab.github.io/Parse-Swift/release/tutorials/parseswift/) [![Build Status CI](https://github.com/netreconlab/Parse-Swift/workflows/ci/badge.svg?branch=main)](https://github.com/netreconlab/Parse-Swift/actions?query=workflow%3Aci+branch%3Amain) [![Build Status Release](https://github.com/netreconlab/Parse-Swift/workflows/release/badge.svg)](https://github.com/netreconlab/Parse-Swift/actions?query=workflow%3Arelease) [![Coverage](https://codecov.io/gh/netreconlab/Parse-Swift/branch/main/graph/badge.svg)](https://codecov.io/gh/netreconlab/Parse-Swift/branches) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/403b74d0f2514e288b0a1b2e52b6d841)](https://www.codacy.com/gh/netreconlab/Parse-Swift/dashboard?utm_source=github.com&utm_medium=referral&utm_content=netreconlab/Parse-Swift&utm_campaign=Badge_Grade) -[![Carthage](https://img.shields.io/badge/carthage-compatible-4BC51D.svg?style=flat)](https://github.com/carthage/carthage) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)][license-link] - [![Swift Versions](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fnetreconlab%2FParse-Swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/netreconlab/Parse-Swift) [![Platforms](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fnetreconlab%2FParse-Swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/netreconlab/Parse-Swift) From 81692b0bc40de7a731a23a7b970b6ce69d043850 Mon Sep 17 00:00:00 2001 From: Corey Baker Date: Sun, 22 Jan 2023 09:51:30 -0500 Subject: [PATCH 3/4] nits --- .../ParseHookFunctionRequestCombineTests.swift | 4 ++-- Tests/ParseSwiftTests/ParseHookFunctionRequestTests.swift | 2 +- .../ParseSwiftTests/ParseHookTriggerRequestCombineTests.swift | 2 +- Tests/ParseSwiftTests/ParseHookTriggerRequestTests.swift | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/ParseSwiftTests/ParseHookFunctionRequestCombineTests.swift b/Tests/ParseSwiftTests/ParseHookFunctionRequestCombineTests.swift index d47fed1f1..b98370081 100644 --- a/Tests/ParseSwiftTests/ParseHookFunctionRequestCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseHookFunctionRequestCombineTests.swift @@ -33,12 +33,12 @@ class ParseHookFunctionRequestCombineTests: XCTestCase { var emailVerified: Bool? var password: String? var authData: [String: [String: String]?]? - + // These are required by ParseCloudUser var sessionToken: String? var _failed_login_count: Int? var _account_lockout_expires_at: Date? - + // Your custom keys var customKey: String? diff --git a/Tests/ParseSwiftTests/ParseHookFunctionRequestTests.swift b/Tests/ParseSwiftTests/ParseHookFunctionRequestTests.swift index 51f1a6701..03f2bf8dd 100644 --- a/Tests/ParseSwiftTests/ParseHookFunctionRequestTests.swift +++ b/Tests/ParseSwiftTests/ParseHookFunctionRequestTests.swift @@ -35,7 +35,7 @@ class ParseHookFunctionRequestTests: XCTestCase { var emailVerified: Bool? var password: String? var authData: [String: [String: String]?]? - + // These are required by ParseCloudUser var sessionToken: String? var _failed_login_count: Int? diff --git a/Tests/ParseSwiftTests/ParseHookTriggerRequestCombineTests.swift b/Tests/ParseSwiftTests/ParseHookTriggerRequestCombineTests.swift index b48f62aee..3e681dafa 100644 --- a/Tests/ParseSwiftTests/ParseHookTriggerRequestCombineTests.swift +++ b/Tests/ParseSwiftTests/ParseHookTriggerRequestCombineTests.swift @@ -30,7 +30,7 @@ class ParseHookTriggerRequestCombineTests: XCTestCase { var emailVerified: Bool? var password: String? var authData: [String: [String: String]?]? - + // These are required by ParseCloudUser var sessionToken: String? var _failed_login_count: Int? diff --git a/Tests/ParseSwiftTests/ParseHookTriggerRequestTests.swift b/Tests/ParseSwiftTests/ParseHookTriggerRequestTests.swift index fce738a07..c31b272ad 100644 --- a/Tests/ParseSwiftTests/ParseHookTriggerRequestTests.swift +++ b/Tests/ParseSwiftTests/ParseHookTriggerRequestTests.swift @@ -31,7 +31,7 @@ class ParseHookTriggerRequestTests: XCTestCase { var emailVerified: Bool? var password: String? var authData: [String: [String: String]?]? - + // These are required by ParseCloudUser var sessionToken: String? var _failed_login_count: Int? From 6fab2c5807ef3cdfca1448a07b7ef6df14ef3a0b Mon Sep 17 00:00:00 2001 From: Corey Date: Sun, 22 Jan 2023 10:00:16 -0500 Subject: [PATCH 4/4] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 14525b1ad..bf30ab59b 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ --- -[![Documentation](http://img.shields.io/badge/read_the-docs-2196f3.svg)](https://swiftpackageindex.com/netreconlab/Parse-Swift/documentation) [![Playgrounds](http://img.shields.io/badge/swift-playgrounds-2196f3.svg)](https://github.com/netreconlab/Parse-Swift/tree/main/ParseSwift.playground/Pages) -[![Tuturiol](http://img.shields.io/badge/read_the-tuturials-2196f3.svg)](https://netreconlab.github.io/Parse-Swift/release/tutorials/parseswift/) +[![Documentation](http://img.shields.io/badge/read_-docs-2196f3.svg)](https://swiftpackageindex.com/netreconlab/Parse-Swift/documentation) +[![Tuturiol](http://img.shields.io/badge/read_-tuturials-2196f3.svg)](https://netreconlab.github.io/Parse-Swift/release/tutorials/parseswift/) [![Build Status CI](https://github.com/netreconlab/Parse-Swift/workflows/ci/badge.svg?branch=main)](https://github.com/netreconlab/Parse-Swift/actions?query=workflow%3Aci+branch%3Amain) [![Build Status Release](https://github.com/netreconlab/Parse-Swift/workflows/release/badge.svg)](https://github.com/netreconlab/Parse-Swift/actions?query=workflow%3Arelease) [![Coverage](https://codecov.io/gh/netreconlab/Parse-Swift/branch/main/graph/badge.svg)](https://codecov.io/gh/netreconlab/Parse-Swift/branches)