minor changes

This commit is contained in:
Dawid Kubicki 2018-11-19 16:58:23 +01:00
parent 06a1fe1077
commit e2afc3ea4c
9 changed files with 188 additions and 14 deletions

View File

@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
123D62D321A3148300D5CD74 /* NoteBiometricViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 123D62D121A3148300D5CD74 /* NoteBiometricViewController.swift */; };
123D62D421A3148300D5CD74 /* NoteBiometricViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 123D62D221A3148300D5CD74 /* NoteBiometricViewController.xib */; };
18F5657D204DD7AF00F128ED /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18F5657C204DD7AF00F128ED /* LaunchScreen.storyboard */; };
48DC83E42012A5D600F82C5D /* FriendCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48DC83E22012A5D600F82C5D /* FriendCell.swift */; };
48DC83E52012A5D600F82C5D /* FriendCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 48DC83E32012A5D600F82C5D /* FriendCell.xib */; };
@ -28,6 +30,8 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
123D62D121A3148300D5CD74 /* NoteBiometricViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteBiometricViewController.swift; sourceTree = "<group>"; };
123D62D221A3148300D5CD74 /* NoteBiometricViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NoteBiometricViewController.xib; sourceTree = "<group>"; };
18F5657C204DD7AF00F128ED /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
48DC83E22012A5D600F82C5D /* FriendCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendCell.swift; sourceTree = "<group>"; };
48DC83E32012A5D600F82C5D /* FriendCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FriendCell.xib; sourceTree = "<group>"; };
@ -133,6 +137,8 @@
48EA9AEE20117C6000146CF7 /* FriendsViewController.swift */,
48EA9AF020117C9000146CF7 /* NavigationController.swift */,
48EA9AD3200FC48100146CF7 /* SplashViewController.swift */,
123D62D121A3148300D5CD74 /* NoteBiometricViewController.swift */,
123D62D221A3148300D5CD74 /* NoteBiometricViewController.xib */,
);
name = ViewControllers;
sourceTree = "<group>";
@ -248,6 +254,7 @@
18F5657D204DD7AF00F128ED /* LaunchScreen.storyboard in Resources */,
48EA9AC8200FC22200146CF7 /* Assets.xcassets in Resources */,
48DC83E52012A5D600F82C5D /* FriendCell.xib in Resources */,
123D62D421A3148300D5CD74 /* NoteBiometricViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -315,6 +322,7 @@
48EA9ADD20110EEE00146CF7 /* KeychainPasswordItem.swift in Sources */,
48EA9AF120117C9000146CF7 /* NavigationController.swift in Sources */,
48EA9AED20117BFC00146CF7 /* UIColor+Additions.swift in Sources */,
123D62D321A3148300D5CD74 /* NoteBiometricViewController.swift in Sources */,
48EA9AD4200FC48100146CF7 /* SplashViewController.swift in Sources */,
48EA9AE020110F2800146CF7 /* User.swift in Sources */,
48EA9ADA2011063600146CF7 /* AuthController.swift in Sources */,

View File

@ -36,7 +36,7 @@ final class AppController {
@objc func handleAuthState() {
if AuthController.isSignedIn {
rootViewController = NavigationController(rootViewController: FriendsViewController())
rootViewController = NavigationController(rootViewController: NoteBiometricViewController())
} else {
rootViewController = AuthViewController()
}

View File

@ -23,6 +23,21 @@ final class AuthController {
return "\(password).\(email).\(salt)".sha256()
}
class func logIn(_ user: User, password: String) throws {
do {
let finalHash = passwordHash(from: user.email, password: password)
let keychainPassword = try KeychainPasswordItem(service: serviceName, account: user.email).readPassword()
print(keychainPassword)
if(keychainPassword == finalHash) {
Settings.currentUser = user
NotificationCenter.default.post(name: .loginStatusChanged, object: nil)
}
} catch {
print("nie dziala")
}
}
class func signIn(_ user: User, password: String) throws {
let finalHash = passwordHash(from: user.email, password: password)
try KeychainPasswordItem(service: serviceName, account: user.email).savePassword(finalHash)
@ -36,7 +51,7 @@ final class AuthController {
return
}
try KeychainPasswordItem(service: serviceName, account: currentUser.email).deleteItem()
//try KeychainPasswordItem(service: serviceName, account: currentUser.email).deleteItem()
Settings.currentUser = nil
NotificationCenter.default.post(name: .loginStatusChanged, object: nil)

View File

@ -1,3 +1,4 @@
import UIKit
final class AuthViewController: UIViewController {
@ -11,6 +12,26 @@ final class AuthViewController: UIViewController {
case password
}
private func logIn() {
view.endEditing(true)
guard let email = emailField.text, email.count > 0 else {
return
}
guard let password = passwordField.text, password.count > 0 else {
return
}
let name = UIDevice.current.name
let user = User(name: name, email: email)
do {
try AuthController.logIn(user, password: password)
} catch {
print("Error signing in: \(error.localizedDescription)")
}
}
@IBOutlet weak var containerView: UIView!
@IBOutlet weak var emailField: UITextField!
@IBOutlet weak var passwordField: UITextField!
@ -18,7 +39,11 @@ final class AuthViewController: UIViewController {
@IBOutlet weak var signInButton: UIButton!
@IBOutlet weak var bottomConstraint: NSLayoutConstraint!
override func viewDidLoad() {
@IBAction func onLogIn(_ sender: Any) {
logIn()
}
@IBOutlet weak var noteField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
containerView.transform = CGAffineTransform(scaleX: 0, y: 0)

View File

@ -15,6 +15,7 @@
<outlet property="bottomConstraint" destination="nvR-sM-xyu" id="sfO-yG-bij"/>
<outlet property="containerView" destination="fIM-wX-ThP" id="MCr-wf-hth"/>
<outlet property="emailField" destination="vrM-BE-Sxz" id="yN0-VF-tnI"/>
<outlet property="noteField" destination="nnj-yi-h3Z" id="84h-ZS-5xw"/>
<outlet property="passwordField" destination="XnE-em-cB7" id="I2k-JM-vRu"/>
<outlet property="signInButton" destination="hSR-Ry-zgR" id="67R-L3-h8e"/>
<outlet property="titleLabel" destination="WHD-fd-dhU" id="y4p-7Q-Mwd"/>
@ -30,19 +31,19 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fIM-wX-ThP">
<rect key="frame" x="32" y="205.5" width="311" height="256"/>
<rect key="frame" x="32" y="193" width="311" height="281"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="47J-gQ-72v">
<rect key="frame" x="12" y="12" width="287" height="232"/>
<rect key="frame" x="12" y="12" width="287" height="257"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="249" text="Login" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jBg-ue-wfi">
<rect key="frame" x="0.0" y="0.0" width="287" height="40"/>
<rect key="frame" x="0.0" y="0.0" width="287" height="45"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="Podaj swój login" borderStyle="roundedRect" placeholder="Enter your email" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="vrM-BE-Sxz">
<rect key="frame" x="0.0" y="48" width="287" height="40"/>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Podaj swoj login" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="vrM-BE-Sxz">
<rect key="frame" x="0.0" y="53" width="287" height="45"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="o9g-dR-A9f"/>
</constraints>
@ -51,13 +52,13 @@
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="emailAddress" keyboardAppearance="alert" enablesReturnKeyAutomatically="YES" smartDashesType="no" smartInsertDeleteType="no" smartQuotesType="no" textContentType="email"/>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hasło" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AMS-r7-phX">
<rect key="frame" x="0.0" y="96" width="287" height="40"/>
<rect key="frame" x="0.0" y="106" width="287" height="45"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="Podaj hasło" borderStyle="roundedRect" placeholder="Enter your password" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="XnE-em-cB7">
<rect key="frame" x="0.0" y="144" width="287" height="40"/>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Podaj swoje haslo" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="XnE-em-cB7">
<rect key="frame" x="0.0" y="159" width="287" height="45"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="r71-Sl-CjK"/>
</constraints>
@ -66,9 +67,9 @@
<textInputTraits key="textInputTraits" keyboardAppearance="alert" secureTextEntry="YES"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hSR-Ry-zgR">
<rect key="frame" x="0.0" y="192" width="287" height="40"/>
<rect key="frame" x="0.0" y="212" width="287" height="45"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/>
<state key="normal" title="Zobacz notatkę">
<state key="normal" title="Zarejestruj się">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
@ -83,22 +84,46 @@
<constraint firstAttribute="trailing" secondItem="XnE-em-cB7" secondAttribute="trailing" id="sJh-f6-THo"/>
</constraints>
</stackView>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DP0-O4-y7W">
<rect key="frame" x="102" y="251" width="107" height="30"/>
<state key="normal" title="Zobacz notatkę">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="onLogIn:" destination="-1" eventType="touchUpInside" id="JQi-Ha-mlD"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
<constraints>
<constraint firstItem="DP0-O4-y7W" firstAttribute="centerX" secondItem="fIM-wX-ThP" secondAttribute="centerX" id="4V3-NP-lzu"/>
<constraint firstItem="DP0-O4-y7W" firstAttribute="centerY" secondItem="fIM-wX-ThP" secondAttribute="centerY" id="CP4-Fd-N8B"/>
<constraint firstAttribute="width" constant="311" id="DbP-S4-tdu"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="281" id="SeW-ed-E9b"/>
<constraint firstAttribute="trailing" secondItem="47J-gQ-72v" secondAttribute="trailing" constant="12" id="WkR-AZ-hfk"/>
<constraint firstItem="47J-gQ-72v" firstAttribute="centerY" secondItem="fIM-wX-ThP" secondAttribute="centerY" id="Yml-f5-C1g"/>
<constraint firstItem="47J-gQ-72v" firstAttribute="top" secondItem="fIM-wX-ThP" secondAttribute="top" constant="12" id="lYI-As-5gY"/>
<constraint firstAttribute="bottom" secondItem="47J-gQ-72v" secondAttribute="bottom" constant="12" id="pTj-6w-3fL"/>
<constraint firstAttribute="height" constant="281" id="pZN-sd-vks"/>
<constraint firstItem="47J-gQ-72v" firstAttribute="leading" secondItem="fIM-wX-ThP" secondAttribute="leading" constant="12" id="tLY-wi-TIE"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="BSM ZADANIE" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WHD-fd-dhU">
<rect key="frame" x="32" y="162" width="311" height="31.5"/>
<rect key="frame" x="32" y="149.5" width="311" height="31.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleTitle1"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" ambiguous="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="nnj-yi-h3Z">
<rect key="frame" x="24" y="20" width="335" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="335" id="Aib-mz-k2j"/>
<constraint firstAttribute="height" constant="30" id="pF6-VC-P8N"/>
</constraints>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
@ -112,10 +137,19 @@
<constraint firstAttribute="bottom" secondItem="fIM-wX-ThP" secondAttribute="bottom" priority="750" constant="100" id="nvR-sM-xyu"/>
<constraint firstItem="tFe-fM-7UZ" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="qHd-7e-hwP"/>
<constraint firstItem="WHD-fd-dhU" firstAttribute="trailing" secondItem="fIM-wX-ThP" secondAttribute="trailing" id="sMj-GC-DPU"/>
<constraint firstItem="fIM-wX-ThP" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" id="tTe-8n-30L"/>
<constraint firstAttribute="trailing" secondItem="tFe-fM-7UZ" secondAttribute="trailing" id="zYh-8O-PJL"/>
</constraints>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
<point key="canvasLocation" x="53.600000000000001" y="102.99850074962519"/>
</view>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" id="UWH-Sg-pV9">
<rect key="frame" x="0.0" y="0.0" width="97" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</objects>
<resources>
<image name="rwdevcon-bg" width="312" height="310.32000732421875"/>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="FriendsViewController" customModule="Friendvatars" customModuleProvider="target"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fVN-Cm-74e">
<rect key="frame" x="164" y="318" width="46" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
</view>
</objects>
</document>

View File

@ -0,0 +1,30 @@
//
// NoteBiometricViewController.swift
// Friendvatars
//
// Created by Dawid Kubicki on 19/11/2018.
// Copyright © 2018 Razeware. All rights reserved.
//
import UIKit
class NoteBiometricViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="NoteBiometricViewController" customModule="Friendvatars" customModuleProvider="target">
<connections>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Gvc-xD-qpV">
<rect key="frame" x="165" y="101" width="82" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Kamil lamus"/>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
</view>
</objects>
</document>