Skip to content

Commit 0292e24

Browse files
committed
Added working logout button
1 parent 8492add commit 0292e24

4 files changed

Lines changed: 48 additions & 16 deletions

File tree

BrickHack-Mobile/Base.lproj/Main.storyboard

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
<rect key="frame" x="0.0" y="0.0" width="375" height="598"/>
2222
<subviews>
2323
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="brickHack6Logo" translatesAutoresizingMaskIntoConstraints="NO" id="1am-Hz-qrF">
24-
<rect key="frame" x="36" y="229.33333333333337" width="148" height="139.66666666666663"/>
24+
<rect key="frame" x="36" y="159.66666666666663" width="296" height="279"/>
2525
</imageView>
2626
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="loginShapes" translatesAutoresizingMaskIntoConstraints="NO" id="QYc-0X-ayY">
27-
<rect key="frame" x="164" y="124.66666666666669" width="211" height="349"/>
27+
<rect key="frame" x="-47" y="-50" width="422" height="698"/>
2828
</imageView>
2929
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Welcome to 
BrickHack" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" minimumFontSize="14" translatesAutoresizingMaskIntoConstraints="NO" id="xNm-NN-nc2">
3030
<rect key="frame" x="36" y="486.66666666666669" width="248" height="81.333333333333314"/>
@@ -258,7 +258,7 @@
258258
</tableViewController>
259259
<placeholder placeholderIdentifier="IBFirstResponder" id="yNf-Aa-cwx" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
260260
</objects>
261-
<point key="canvasLocation" x="5364" y="-251.23152709359607"/>
261+
<point key="canvasLocation" x="5364" y="-207"/>
262262
</scene>
263263
<!--Resources View Controller-->
264264
<scene sceneID="UT5-X6-ZKF">
@@ -284,28 +284,55 @@
284284
<nil key="highlightedColor"/>
285285
</label>
286286
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nwl-VF-xjf">
287-
<rect key="frame" x="0.0" y="270" width="375" height="508"/>
287+
<rect key="frame" x="0.0" y="270" width="375" height="365"/>
288288
<connections>
289289
<segue destination="2e9-Rl-UDW" kind="embed" id="0EE-Cc-IyJ"/>
290290
</connections>
291291
</containerView>
292+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jAn-JA-reA">
293+
<rect key="frame" x="131" y="655" width="112" height="40"/>
294+
<color key="backgroundColor" name="primaryColor"/>
295+
<constraints>
296+
<constraint firstAttribute="height" constant="40" id="HDX-SR-cd8"/>
297+
</constraints>
298+
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
299+
<state key="normal" title="Logout">
300+
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
301+
<color key="titleShadowColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
302+
</state>
303+
<userDefinedRuntimeAttributes>
304+
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
305+
<integer key="value" value="5"/>
306+
</userDefinedRuntimeAttribute>
307+
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.matchToBounds" value="YES"/>
308+
<userDefinedRuntimeAttribute type="boolean" keyPath="titleLabel.adjustsFontSizeToFitWidth" value="YES"/>
309+
</userDefinedRuntimeAttributes>
310+
<connections>
311+
<action selector="initializeOAuth:" destination="BYZ-38-t0r" eventType="touchUpInside" id="wHz-Su-Dc7"/>
312+
<segue destination="6Q1-Id-c6M" kind="unwind" unwindAction="unwindToLoginWithSegue:" id="KAA-dg-wSI"/>
313+
</connections>
314+
</button>
292315
</subviews>
293316
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
294317
<constraints>
295318
<constraint firstItem="jaN-ia-Njg" firstAttribute="trailing" secondItem="g6R-ba-pGl" secondAttribute="trailing" id="16d-mI-7jP"/>
319+
<constraint firstItem="jAn-JA-reA" firstAttribute="top" secondItem="nwl-VF-xjf" secondAttribute="bottom" constant="20" id="86Y-Le-l5v"/>
296320
<constraint firstItem="g6R-ba-pGl" firstAttribute="leading" secondItem="jaN-ia-Njg" secondAttribute="leading" id="8Wo-XH-hWO"/>
297321
<constraint firstItem="nwl-VF-xjf" firstAttribute="top" secondItem="g6R-ba-pGl" secondAttribute="bottom" constant="40" id="FOi-Lg-qMQ"/>
298-
<constraint firstItem="jaN-ia-Njg" firstAttribute="bottom" secondItem="nwl-VF-xjf" secondAttribute="bottom" id="VHo-LA-vbb"/>
299322
<constraint firstItem="jaN-ia-Njg" firstAttribute="trailing" secondItem="nwl-VF-xjf" secondAttribute="trailing" id="YhI-wM-gCW"/>
300323
<constraint firstItem="wxT-LE-0Pv" firstAttribute="top" secondItem="jaN-ia-Njg" secondAttribute="top" constant="20" id="Z79-Cb-9zm"/>
324+
<constraint firstItem="jAn-JA-reA" firstAttribute="leading" secondItem="jaN-ia-Njg" secondAttribute="leading" constant="131" id="eZV-tg-QC8"/>
325+
<constraint firstItem="jaN-ia-Njg" firstAttribute="trailing" secondItem="jAn-JA-reA" secondAttribute="trailing" constant="132" id="flF-wJ-bFm"/>
301326
<constraint firstItem="nwl-VF-xjf" firstAttribute="leading" secondItem="jaN-ia-Njg" secondAttribute="leading" id="iAi-WL-HZZ"/>
327+
<constraint firstItem="jaN-ia-Njg" firstAttribute="bottom" secondItem="nwl-VF-xjf" secondAttribute="bottom" constant="143" id="ql7-X4-NqB"/>
302328
<constraint firstItem="wxT-LE-0Pv" firstAttribute="leading" secondItem="jaN-ia-Njg" secondAttribute="leading" constant="15" id="rJ0-J0-DzT"/>
303329
<constraint firstItem="g6R-ba-pGl" firstAttribute="top" secondItem="wxT-LE-0Pv" secondAttribute="bottom" constant="20" id="rqv-2A-ZQW"/>
304330
</constraints>
305331
<viewLayoutGuide key="safeArea" id="jaN-ia-Njg"/>
306332
</view>
307333
</viewController>
308334
<placeholder placeholderIdentifier="IBFirstResponder" id="wKq-zV-HKi" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
335+
<exit id="6Q1-Id-c6M" userLabel="Exit" sceneMemberID="exit"/>
309336
</objects>
310337
<point key="canvasLocation" x="4568.8000000000002" y="-18.472906403940886"/>
311338
</scene>
@@ -314,7 +341,7 @@
314341
<objects>
315342
<tableViewController id="2e9-Rl-UDW" customClass="ResourcesTableViewController" customModule="BrickHack_Mobile" customModuleProvider="target" sceneMemberID="viewController">
316343
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" scrollEnabled="NO" dataMode="static" style="grouped" separatorStyle="default" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="Ejc-ID-4PC">
317-
<rect key="frame" x="0.0" y="0.0" width="375" height="528"/>
344+
<rect key="frame" x="0.0" y="0.0" width="375" height="395"/>
318345
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
319346
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
320347
<sections>
@@ -519,7 +546,7 @@
519546
</tableViewController>
520547
<placeholder placeholderIdentifier="IBFirstResponder" id="cRh-Pi-L69" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
521548
</objects>
522-
<point key="canvasLocation" x="5412" y="272.66009852216752"/>
549+
<point key="canvasLocation" x="5364" y="104"/>
523550
</scene>
524551
<!--Schedule Table View Controller-->
525552
<scene sceneID="up2-D5-I0e">

BrickHack-Mobile/Controllers/EventsViewController.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,4 @@ class EventsViewController: UIViewController { //UserDataHandler {
2020
super.viewDidLoad()
2121
}
2222

23-
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
24-
25-
// Logout segue -- logout user before loading login view
26-
if let loginVC = segue.destination as? LoginViewController {
27-
loginVC.logout()
28-
}
29-
30-
}
31-
3223
}

BrickHack-Mobile/Controllers/LoginViewController.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class LoginViewController: UIViewController {
4242
}
4343

4444
// Set authorization method
45+
// SFSafariViewController is sandboxed, so we need to use
46+
// p2_Oauth2's *embedded* view for auth, which allows US to
47+
// reset cookies and prevent insta-login.
48+
// @TODO: This causes some layoutconstraint bugs maybe. Maybe.
49+
oauthGrant.authConfig.ui.useSafariView = false
4550
oauthGrant.authConfig.authorizeEmbedded = true
4651
oauthGrant.authConfig.authorizeContext = self
4752

BrickHack-Mobile/Controllers/ResourcesViewController.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ResourcesViewController: UIViewController {
2121

2222
}
2323

24+
// MARK: PrepareForSegue
2425
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
2526

2627
// Embedded TableViewController segue
@@ -33,5 +34,13 @@ class ResourcesViewController: UIViewController {
3334
tableVC.infoText = "Majoring in " + currentUser.major
3435

3536
}
37+
38+
// Logout segue -- logout user before loading login view
39+
if let loginVC = segue.destination as? LoginViewController {
40+
print("\n\nLOGGED OUT\n\n")
41+
loginVC.logout()
42+
}
43+
3644
}
45+
3746
}

0 commit comments

Comments
 (0)