Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogerets committed Aug 21, 2019
1 parent 5b721fb commit 4511d34
Showing 1 changed file with 3 additions and 30 deletions.
33 changes: 3 additions & 30 deletions Source/PublicAPI/EThree+Authorization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,38 +73,11 @@ extension EThree {
}
}

/// Generates new Private Key, publishes Card on Virgil Cards Service and saves Private Key in local storage
/// Publishes Card on Virgil Cards Service and saves Private Key in local storage
///
/// - Parameter keyPair: `VirgilKeyPair` to publish Card with. Will generate if not specified
/// - Returns: CallbackOperation<Void>
public func register() -> GenericOperation<Void> {
return CallbackOperation { _, completion in
self.queue.async {
do {
guard try !self.localKeyStorage.exists() else {
throw EThreeError.privateKeyExists
}

let cards = try self.cardManager.searchCards(identities: [self.identity]).startSync().get()

guard cards.isEmpty else {
throw EThreeError.userIsAlreadyRegistered
}

try self.publishCardThenSaveLocal()

completion((), nil)
} catch {
completion(nil, error)
}
}
}
}

/// Uses provided Private Key to publish Card to Virgil Cards Service. Saves Private Key in local storage
///
/// - Parameter keyPair: Key Pair to publish Card with
/// - Returns: CallbackOperation<Void>
public func register(with keyPair: VirgilKeyPair) -> GenericOperation<Void> {
public func register(with keyPair: VirgilKeyPair? = nil) -> GenericOperation<Void> {
return CallbackOperation { _, completion in
self.queue.async {
do {
Expand Down

0 comments on commit 4511d34

Please sign in to comment.