Skip to content

Commit

Permalink
fix issue #16 - On login ask for username instead of email - udacity/…
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent Mifsud committed Jun 2, 2019
1 parent 91b0fbe commit 23e6c15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions TheMovieManager/Controller/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

class LoginViewController: UIViewController {

@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var loginButton: UIButton!
@IBOutlet weak var loginViaWebsiteButton: UIButton!
Expand All @@ -19,7 +19,7 @@ class LoginViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

emailTextField.text = ""
usernameTextField.text = ""
passwordTextField.text = ""
}

Expand All @@ -45,7 +45,7 @@ class LoginViewController: UIViewController {
} else {
activityIndicator.stopAnimating()
}
emailTextField.isEnabled = !loggingIn
usernameTextField.isEnabled = !loggingIn
passwordTextField.isEnabled = !loggingIn
loginButton.isEnabled = !loggingIn
loginViaWebsiteButton.isEnabled = !loggingIn
Expand All @@ -62,7 +62,7 @@ class LoginViewController: UIViewController {
extension LoginViewController {
func handleRequestTokenResponse(success: Bool, error: Error?){
if success {
TMDBClient.login(username: self.emailTextField.text ?? "", password: self.passwordTextField.text ?? "", completion: self.handleLoginResponse(success:error:))
TMDBClient.login(username: self.usernameTextField.text ?? "", password: self.passwordTextField.text ?? "", completion: self.handleLoginResponse(success:error:))
} else {
setLoggingIn(false)
showLoginFailure(message: error?.localizedDescription ?? "")
Expand Down
6 changes: 3 additions & 3 deletions TheMovieManager/View/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="6au-LF-Utu">
<rect key="frame" x="16" y="195.5" width="343" height="296"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Login with Email" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mar-mo-B2j">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Login with Username" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mar-mo-B2j" userLabel="Login with Username">
<rect key="frame" x="0.0" y="0.0" width="343" height="32"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Email" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="qrT-hl-seK" customClass="LoginTextField" customModule="TheMovieManager" customModuleProvider="target">
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Username" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="qrT-hl-seK" customClass="LoginTextField" customModule="TheMovieManager" customModuleProvider="target">
<rect key="frame" x="0.0" y="44" width="343" height="32"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="32" id="k43-y2-3qE"/>
Expand Down Expand Up @@ -117,10 +117,10 @@
</view>
<connections>
<outlet property="activityIndicator" destination="WMn-Lf-WGT" id="KVb-Bi-dge"/>
<outlet property="emailTextField" destination="qrT-hl-seK" id="kNU-Rr-pdO"/>
<outlet property="loginButton" destination="XfA-1k-xWc" id="gzO-wf-ODd"/>
<outlet property="loginViaWebsiteButton" destination="OHw-m7-7gh" id="Ghg-Tm-X1E"/>
<outlet property="passwordTextField" destination="R9P-8h-YZr" id="3kW-y3-iTs"/>
<outlet property="usernameTextField" destination="qrT-hl-seK" id="kNU-Rr-pdO"/>
<segue destination="KyE-Nk-bg6" kind="presentation" identifier="completeLogin" id="aGP-QK-myr"/>
</connections>
</viewController>
Expand Down

0 comments on commit 23e6c15

Please sign in to comment.