Skip to content

Commit

Permalink
Merge pull request #143 from DimensionSrl/feature/updates
Browse files Browse the repository at this point in the history
Improves email check on login
  • Loading branch information
dulvui authored Feb 29, 2024
2 parents a34e30a + d047ca5 commit a4d4194
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
11 changes: 10 additions & 1 deletion NOICommunity/AuthFeature/LoadUserInfoViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ final class LoadUserInfoViewModel {
guard let userEmail = userInfo.email
else { return false }

return userEmail == person.email ||
return person.hasEmail(userEmail) ||
userEmail == "[email protected]" ||
userEmail.hasSuffix("@dimension.it")
}
Expand Down Expand Up @@ -104,3 +104,12 @@ final class LoadUserInfoViewModel {
)
}
}

private extension Person {

func hasEmail(_ email: String) -> Bool {
let emails = [primaryEmail, secondaryEmail, tertiaryEmail].compactMap { $0 }
return emails.contains { $0.compare(email, options: .caseInsensitive) == .orderedSame }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private extension MeetCoordinator {

detailVC.composeMailActionPublisher.sink { [weak navigationController] in
navigationController?.mailTo(
person.email!,
person.primaryEmail!,
delegate: self,
completion: nil
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class PersonDetailsViewController: UIViewController {
.configureAsSecondaryActionButton(numberOfLines: 1)
.withTitle(.localized("btn_mail"))

mailButton.isHidden = person.email == nil
mailButton.isHidden = person.primaryEmail == nil
}
}

Expand Down Expand Up @@ -245,7 +245,7 @@ private extension PersonDetailsViewController.CollectionViewController {
contentConfiguration.text = info.localizedString
switch info {
case .email:
contentConfiguration.secondaryText = person.email
contentConfiguration.secondaryText = person.primaryEmail
case .phoneNumber:
contentConfiguration.secondaryText = company?.phoneNumber
case .address:
Expand Down Expand Up @@ -342,7 +342,7 @@ private extension PersonDetailsViewController.CollectionViewController {
snapshot.appendSections([.main])
let diplayItems = {
var result = Info.allCases
if person.email == nil {
if person.primaryEmail == nil {
result.removeAll { $0 == .email }
}
if company?.phoneNumber == nil {
Expand Down Expand Up @@ -376,7 +376,7 @@ extension PersonDetailsViewController.CollectionViewController {

switch selectedInfo {
case .email:
UIPasteboard.general.string = person.email!
UIPasteboard.general.string = person.primaryEmail!
case .phoneNumber:
UIPasteboard.general.string = company!.phoneNumber!
case .address:
Expand Down
8 changes: 6 additions & 2 deletions NOICommunityLib/Sources/PeopleClient/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ public struct Person: Codable {
public var firstname: String
public var lastname: String
public var fullname: String
public var email: String?
public var primaryEmail: String?
public var secondaryEmail: String?
public var tertiaryEmail: String?
public var companyId: String?

private enum CodingKeys: String, CodingKey {
case id = "contactid"
case email = "emailaddress1"
case primaryEmail = "emailaddress1"
case secondaryEmail = "emailaddress2"
case tertiaryEmail = "emailaddress3"
case firstname
case lastname
case fullname
Expand Down
2 changes: 1 addition & 1 deletion NOICommunityLib/Sources/PeopleClientLive/Endpoints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension Endpoint {

URLQueryItem(
name: "$select",
value: "emailaddress1,firstname,lastname,fullname,_parentcustomerid_value"
value: "emailaddress1,emailaddress2,emailaddress3,firstname,lastname,fullname,_parentcustomerid_value"
)

URLQueryItem(
Expand Down

0 comments on commit a4d4194

Please sign in to comment.