-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfe4f9e
commit 5014e7f
Showing
14 changed files
with
211 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+4.76 KB
(120%)
HackIllinois: QR.xcworkspace/xcuserdata/ymostofi.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
HackIllinois: QR/Assets.xcassets/hackillinois.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "landing-logo-2.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "landing-logo.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "landing-logo-1.png", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+8.4 KB
HackIllinois: QR/Assets.xcassets/hackillinois.imageset/landing-logo-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.4 KB
HackIllinois: QR/Assets.xcassets/hackillinois.imageset/landing-logo-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.4 KB
HackIllinois: QR/Assets.xcassets/hackillinois.imageset/landing-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// ScanViewController.swift | ||
// HackIllinois: QR | ||
// | ||
// Created by Yasha Mostofi on 2/14/17. | ||
// Copyright © 2017 Yasha Mostofi. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import AVFoundation | ||
import SwiftQRCode | ||
import Alamofire | ||
import Foundation | ||
|
||
|
||
class ScanViewController: UIViewController { | ||
let scanner = QRCode() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
print("other view loaded") | ||
|
||
scanner.prepareScan(view) { (stringValue) -> () in | ||
print(stringValue) | ||
self.scanner.stopScan() | ||
let alert = UIAlertController(title: "data", message: stringValue, preferredStyle: .alert) | ||
let okayAction = UIAlertAction(title: "okay", style: .default) { [weak self] (_) in | ||
self?.scanner.startScan() | ||
} | ||
alert.addAction(okayAction) | ||
DispatchQueue.main.async { [weak self] in | ||
self?.present(alert, animated: true) { | ||
} | ||
} | ||
} | ||
scanner.scanFrame = view.bounds | ||
scanner.startScan() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,88 +23,93 @@ class ViewController: UIViewController { | |
let checksession_url = "https://api.hackillinois.org/v1/auth/reset" | ||
var login_session:String = "" | ||
|
||
let scanner = QRCode() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
print("view loaded") | ||
|
||
|
||
/* | ||
scanner.prepareScan(view) { (stringValue) -> () in | ||
print(stringValue) | ||
self.scanner.stopScan() | ||
let alert = UIAlertController(title: "data", message: stringValue, preferredStyle: .alert) | ||
let okayAction = UIAlertAction(title: "okay", style: .default) { [weak self] (_) in | ||
self?.scanner.startScan() | ||
} | ||
alert.addAction(okayAction) | ||
DispatchQueue.main.async { [weak self] in | ||
self?.present(alert, animated: true) { | ||
} | ||
} | ||
} | ||
scanner.scanFrame = view.bounds | ||
*/ | ||
|
||
// email_input.text = "[email protected]" | ||
// password_input.text = "test" | ||
|
||
/* | ||
// Uncomment to save auth key between app opens | ||
let preferences = UserDefaults.standard | ||
if preferences.object(forKey: "session") != nil | ||
{ | ||
login_session = preferences.object(forKey: "session") as! String | ||
check_session(key: login_session) | ||
scanner.startScan() | ||
} | ||
*/ | ||
} | ||
|
||
func logIn(email: String, password: String) { | ||
let parameters: Parameters = [ | ||
"email": email, | ||
"password": password | ||
] | ||
|
||
// Both calls are equivalent | ||
Alamofire.request("https://api.hackillinois.org/v1/auth", method: .post, | ||
parameters: parameters, | ||
encoding: JSONEncoding.default).responseJSON { response in | ||
// print(response.request) // original URL request | ||
// print(response.response) // HTTP URL response | ||
// print(response.data) // server data | ||
// print(response.result) // result of response serialization | ||
|
||
if let json = response.result.value { | ||
if let jsonDict = json as? [String: Any] { | ||
if let dataVal = jsonDict["data"] as? [String: Any] { | ||
if let authKey = dataVal["auth"] as? String { | ||
self.login_session = authKey | ||
let preferences = UserDefaults.standard | ||
preferences.set(authKey, forKey: "session") | ||
print(authKey) | ||
self.scanner.startScan() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
let preferences = UserDefaults.standard | ||
if preferences.object(forKey: "session") != nil | ||
{ | ||
login_session = preferences.object(forKey: "session") as! String | ||
check_session(key: login_session) | ||
// scanner.startScan() | ||
performSegue(withIdentifier: "ShowScanner", sender: self) | ||
} | ||
else { | ||
let parameters: Parameters = [ | ||
"email": email, | ||
"password": password | ||
] | ||
Alamofire.request("https://api.hackillinois.org/v1/auth", method: .post, | ||
parameters: parameters, | ||
encoding: JSONEncoding.default).responseJSON { [weak self] response in | ||
if let json = response.result.value { | ||
if let jsonDict = json as? [String: Any] { | ||
if let dataVal = jsonDict["data"] as? [String: Any] { | ||
if let authKey = dataVal["auth"] as? String { | ||
self?.login_session = authKey | ||
let preferences = UserDefaults.standard | ||
preferences.set(authKey, forKey: "session") | ||
// print(authKey) | ||
// self.scanner.startScan() | ||
self?.performSegue(withIdentifier: "ShowScanner", sender: self) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func check_session(key: String) { | ||
let parameters: Parameters = [ | ||
"Authorization": key | ||
] | ||
|
||
// Both calls are equivalent | ||
Alamofire.request("https://api.hackillinois.org/v1/auth/refresh", method: .get, | ||
parameters: parameters, | ||
encoding: JSONEncoding.default).responseJSON { response in | ||
// print(response.request) // original URL request | ||
// print(response.response) // HTTP URL response | ||
// print(response.data) // server data | ||
// print(response.result) // result of response serialization | ||
|
||
if let json = response.result.value { | ||
if let jsonDict = json as? [String: Any] { | ||
if let dataVal = jsonDict["data"] as? [String: Any] { | ||
if let authKey = dataVal["auth"] as? String { | ||
self.login_session = authKey | ||
let preferences = UserDefaults.standard | ||
preferences.set(authKey, forKey: "session") | ||
print(authKey) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.