Skip to content

Delete account #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 42 additions & 34 deletions Example/Pluto-Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="LKr-9C-9l2">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="LKr-9C-9l2">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -45,14 +45,14 @@
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bkw-KG-dld">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bkw-KG-dld">
<rect key="frame" x="168.5" y="174" width="38" height="30"/>
<state key="normal" title="Login"/>
<connections>
<action selector="loginWithEmail:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="MH4-OK-IeY"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5eU-6d-pwr">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5eU-6d-pwr">
<rect key="frame" x="128.5" y="617" width="118" height="30"/>
<state key="normal" title="Register by email"/>
<connections>
Expand Down Expand Up @@ -107,7 +107,7 @@
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sie-Br-ogJ">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sie-Br-ogJ">
<rect key="frame" x="163" y="232" width="49" height="30"/>
<state key="normal" title="Submit"/>
<connections>
Expand Down Expand Up @@ -186,35 +186,47 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OXJ-5s-9Xt">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OXJ-5s-9Xt">
<rect key="frame" x="147.5" y="88" width="80" height="80"/>
<connections>
<action selector="uploadAvatar:" destination="PkW-NZ-hv0" eventType="touchUpInside" id="UNk-lc-64g"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zqu-ew-yj6">
<rect key="frame" x="140" y="597" width="95" height="30"/>
<state key="normal" title="Refresh token"/>
<connections>
<action selector="refresh:" destination="PkW-NZ-hv0" eventType="touchUpInside" id="xBy-qd-DJS"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eZk-UD-zl9">
<rect key="frame" x="142" y="559" width="91" height="30"/>
<state key="normal" title="Show scopes"/>
<connections>
<action selector="showScopes:" destination="PkW-NZ-hv0" eventType="touchUpInside" id="EJF-HF-nEk"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0J1-Sy-deq">
<rect key="frame" x="124.5" y="521" width="126" height="30"/>
<state key="normal" title="Update user name"/>
<connections>
<action selector="updateName:" destination="PkW-NZ-hv0" eventType="touchUpInside" id="M4z-JD-0RG"/>
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="AVB-5C-NPe">
<rect key="frame" x="124.5" y="483" width="126" height="144"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0J1-Sy-deq">
<rect key="frame" x="0.0" y="0.0" width="126" height="30"/>
<state key="normal" title="Update user name"/>
<connections>
<action selector="updateName:" destination="PkW-NZ-hv0" eventType="touchUpInside" id="M4z-JD-0RG"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eZk-UD-zl9">
<rect key="frame" x="17.5" y="38" width="91" height="30"/>
<state key="normal" title="Show scopes"/>
<connections>
<action selector="showScopes:" destination="PkW-NZ-hv0" eventType="touchUpInside" id="EJF-HF-nEk"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zqu-ew-yj6">
<rect key="frame" x="15.5" y="76" width="95" height="30"/>
<state key="normal" title="Refresh token"/>
<connections>
<action selector="refresh:" destination="PkW-NZ-hv0" eventType="touchUpInside" id="xBy-qd-DJS"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dPI-YF-Raj">
<rect key="frame" x="10.5" y="114" width="105" height="30"/>
<state key="normal" title="Delete Account"/>
<connections>
<action selector="deleteAccount:" destination="PkW-NZ-hv0" eventType="touchUpInside" id="rvA-At-uoD"/>
</connections>
</button>
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="K7D-96-cJJ">
<rect key="frame" x="166" y="187" width="43" height="21"/>
<rect key="frame" x="166.5" y="187" width="42.5" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand All @@ -223,19 +235,15 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="CDx-vy-hRh" firstAttribute="centerX" secondItem="uSB-pY-S7p" secondAttribute="centerX" id="5YR-7T-YwG"/>
<constraint firstItem="zqu-ew-yj6" firstAttribute="top" secondItem="eZk-UD-zl9" secondAttribute="bottom" constant="8" id="G2a-vJ-ACb"/>
<constraint firstItem="AVB-5C-NPe" firstAttribute="centerX" secondItem="uSB-pY-S7p" secondAttribute="centerX" id="Ad8-0L-9rF"/>
<constraint firstItem="OXJ-5s-9Xt" firstAttribute="bottom" secondItem="CDx-vy-hRh" secondAttribute="bottom" id="Hda-sc-K8H"/>
<constraint firstItem="xCI-fA-ZZv" firstAttribute="top" secondItem="zqu-ew-yj6" secondAttribute="bottom" constant="20" id="Ikr-Nx-P2J"/>
<constraint firstItem="zqu-ew-yj6" firstAttribute="centerX" secondItem="uSB-pY-S7p" secondAttribute="centerX" id="J4Z-WN-cCr"/>
<constraint firstItem="xCI-fA-ZZv" firstAttribute="top" secondItem="AVB-5C-NPe" secondAttribute="bottom" constant="20" id="RU7-tS-IAh"/>
<constraint firstItem="K7D-96-cJJ" firstAttribute="top" secondItem="OXJ-5s-9Xt" secondAttribute="bottom" constant="19" id="U0R-im-W4g"/>
<constraint firstItem="OXJ-5s-9Xt" firstAttribute="leading" secondItem="CDx-vy-hRh" secondAttribute="leading" id="YNI-3g-qwH"/>
<constraint firstItem="K7D-96-cJJ" firstAttribute="centerX" secondItem="uSB-pY-S7p" secondAttribute="centerX" id="aM6-aQ-dXP"/>
<constraint firstItem="CDx-vy-hRh" firstAttribute="top" secondItem="sMq-pN-e1s" secondAttribute="bottom" constant="32" id="bfL-nj-xYJ"/>
<constraint firstItem="eZk-UD-zl9" firstAttribute="top" secondItem="0J1-Sy-deq" secondAttribute="bottom" constant="8" id="cVK-1J-0zZ"/>
<constraint firstItem="OXJ-5s-9Xt" firstAttribute="trailing" secondItem="CDx-vy-hRh" secondAttribute="trailing" id="f0X-TQ-uIe"/>
<constraint firstItem="0J1-Sy-deq" firstAttribute="centerX" secondItem="uSB-pY-S7p" secondAttribute="centerX" id="s2h-0V-dd2"/>
<constraint firstItem="OXJ-5s-9Xt" firstAttribute="top" secondItem="CDx-vy-hRh" secondAttribute="top" id="xRc-Ra-YPe"/>
<constraint firstItem="eZk-UD-zl9" firstAttribute="centerX" secondItem="uSB-pY-S7p" secondAttribute="centerX" id="yoB-Qr-DBO"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="Pluto" id="Xyp-lr-N8S"/>
Expand Down
27 changes: 17 additions & 10 deletions Example/Pluto-Example/UserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import PlutoSDK
import Kingfisher

class UserViewController: UIViewController {

@IBOutlet weak var avatarImageView: UIImageView!
@IBOutlet weak var nameLabel: UILabel!

private lazy var imagePickerController: UIImagePickerController = {
let imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
Expand All @@ -23,34 +23,34 @@ class UserViewController: UIViewController {
]
return imagePickerController
}()

override func viewDidLoad() {
super.viewDidLoad()

Pluto.shared.myInfo(success: { [weak self] in
self?.set(user: $0)
}, error: {
print("Error loading user info: \($0)")
})
}

@IBAction func refresh(_ sender: Any) {
Pluto.shared.getAccessToken(isForceRefresh: true) { [weak self] in
self?.showAlert(title: "token", content: $0 ?? "")
}
}

@IBAction func showScopes(_ sender: Any) {
Pluto.shared.getScopes { [weak self] in
self?.showAlert(title: "scopes", content: $0.description)
}
}

private func set(user: PlutoUser) {
avatarImageView.kf.setImage(with: URL(string: user.avatar))
nameLabel.text = user.name
}

@IBAction func uploadAvatar(_ sender: Any) {
let alertController = UIAlertController(
title: "Update Avatar",
Expand Down Expand Up @@ -79,7 +79,7 @@ class UserViewController: UIViewController {
alertController.popoverPresentationController?.sourceRect = avatarImageView.bounds
present(alertController, animated: true)
}

@IBAction func updateName(_ sender: Any) {
let alertController = UIAlertController(
title: "Update user name",
Expand Down Expand Up @@ -109,7 +109,14 @@ class UserViewController: UIViewController {
alertController.addAction(cancelAction)
present(alertController, animated: true)
}


@IBAction func deleteAccount(_ sender: Any) {
Pluto.shared.deleteAccount(success: { [unowned self] in
self.dismiss(animated: true)
}, error: { error in
print(error)
})
}
}


Expand Down
12 changes: 6 additions & 6 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PODS:
- Alamofire (5.4.1)
- Kingfisher (6.0.1)
- PlutoSDK/Core (1.0.1):
- Kingfisher (6.3.1)
- PlutoSDK/Core (1.1.0):
- Alamofire (~> 5)
- SwiftyJSON (~> 5)
- SwiftyUserDefaults (~> 5)
- PlutoSDK/Rx (1.0.1):
- PlutoSDK/Rx (1.1.0):
- PlutoSDK/Core (~> 1)
- RxCocoa (~> 6)
- RxCocoa (6.0.0):
Expand Down Expand Up @@ -37,8 +37,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Alamofire: 2291f7d21ca607c491dd17642e5d40fdcda0e65c
Kingfisher: adde87a4f74f6a3845395769354efff593581740
PlutoSDK: 34b5cc344d9074026d1f8f516d4f891f3858c102
Kingfisher: 016c8b653a35add51dd34a3aba36b580041acc74
PlutoSDK: af131f168020f40bd967d6e6e57f6675ba454ace
RxCocoa: 3f79328fafa3645b34600f37c31e64c73ae3a80e
RxRelay: 8d593be109c06ea850df027351beba614b012ffb
RxSwift: c14e798c59b9f6e9a2df8fd235602e85cc044295
Expand All @@ -47,4 +47,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 2e5513e74b0475c9762d494f382ce658831b8a96

COCOAPODS: 1.10.1
COCOAPODS: 1.11.3
23 changes: 23 additions & 0 deletions Pluto/Classes/Core/Pluto+Login.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,29 @@ extension Pluto {
state = .notSignIn
completion?()
}

public func deleteAccount(success: @escaping (() -> Void), error: ErrorCompletion? = nil) {
let requestUrl = url(from: "/v1/user/delete")
getHeaders {
AF.request(
requestUrl,
method: .post,
parameters: nil,
encoding: JSONEncoding.default,
headers: $0
).responseJSON {
let response = PlutoResponse($0)
if response.statusOK() {
DefaultsManager.shared.clear()
self.state = .notSignIn

success()
} else {
error?(response.getError())
}
}
}
}

private func handleLogin(response: PlutoResponse, success: (() -> Void)?, error: ErrorCompletion?) {
if response.statusOK() {
Expand Down
2 changes: 1 addition & 1 deletion PlutoSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'PlutoSDK'
s.version = '1.0.1'
s.version = '1.1.0'
s.summary = 'Swift SDK for Pluto login microservice.'

# This description is used to generate tags and improve search results.
Expand Down