Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

GREENHOUSE-520 added ability to create an account

  • Loading branch information...
commit 176fb4d8cb3b7e6042c023d37be3fbf1240d1b18 1 parent dbbe2bb
@royclarkson royclarkson authored
Showing with 3,673 additions and 736 deletions.
  1. +64 −32 Greenhouse.xcodeproj/project.pbxproj
  2. +9 −5 Greenhouse/{GHOAuth2Controller.h → GHAuthController.h}
  3. +239 −0 Greenhouse/GHAuthController.m
  4. +30 −0 Greenhouse/GHAuthControllerDelegate.h
  5. +0 −60 Greenhouse/GHAuthorizeNavigationViewController.m
  6. +5 −1 Greenhouse/GHAuthorizeViewController.h
  7. +25 −4 Greenhouse/GHAuthorizeViewController.m
  8. +3 −2 Greenhouse/GHAuthorizedRequest.m
  9. +4 −5 Greenhouse/GHEventsMainViewController.m
  10. +5 −4 Greenhouse/{GHAuthorizeNavigationViewController.h → GHFormTextFieldCell.h}
  11. +30 −0 Greenhouse/GHFormTextFieldCell.m
  12. +58 −0 Greenhouse/GHJoinNowViewController.h
  13. +525 −0 Greenhouse/GHJoinNowViewController.m
  14. +0 −91 Greenhouse/GHOAuth2Controller.m
  15. +3 −2 Greenhouse/GHProfileMainViewController.m
  16. +2 −2 Greenhouse/GHSignInViewController.h
  17. +39 −81 Greenhouse/GHSignInViewController.m
  18. +42 −0 Greenhouse/GHSignUpForm.h
  19. +101 −0 Greenhouse/GHSignUpForm.m
  20. +9 −11 Greenhouse/Greenhouse-Prefix.pch
  21. +1 −4 Greenhouse/GreenhouseAppDelegate.h
  22. +9 −18 Greenhouse/GreenhouseAppDelegate.m
  23. +0 −317 Greenhouse/en.lproj/GHAuthorizeNavigationViewController.xib
  24. +283 −23 Greenhouse/en.lproj/GHAuthorizeViewController.xib
  25. +1,897 −0 Greenhouse/en.lproj/GHJoinNowViewController.xib
  26. +5 −43 Greenhouse/en.lproj/GHProfileMainViewController.xib
  27. +4 −5 Greenhouse/en.lproj/GHSignInViewController.xib
  28. +63 −12 Greenhouse/en.lproj/MainWindow.xib
  29. +2 −2 GreenhouseApplicationTests/{GHOauth2ControllerTests.h → GHAuthControllerTests.h}
  30. +8 −8 GreenhouseApplicationTests/{GHOauth2ControllerTests.m → GHAuthControllerTests.m}
  31. +4 −1 GreenhouseApplicationTests/GreenhouseApplicationTests-Prefix.pch
  32. +2 −2 GreenhouseLogicTests/GHServiceValidator.m
  33. +27 −0 GreenhouseLogicTests/GHSignUpFormTests.h
  34. +172 −0 GreenhouseLogicTests/GHSignUpFormTests.m
  35. +3 −1 GreenhouseLogicTests/GreenhouseLogicTests-Prefix.pch
View
96 Greenhouse.xcodeproj/project.pbxproj
@@ -10,10 +10,13 @@
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
2892E4100DC94CBA00A64D0F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */; };
- 810FD30715D99E9200A9B3B3 /* GHAuthorizeNavigationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 810FD30515D99E9200A9B3B3 /* GHAuthorizeNavigationViewController.m */; };
+ 8106BD6E160FA65C003968DB /* GHSignUpForm.m in Sources */ = {isa = PBXBuildFile; fileRef = 8106BD6D160FA65C003968DB /* GHSignUpForm.m */; };
810FD30D15D9A0AE00A9B3B3 /* GHSignInViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 810FD30B15D9A0AE00A9B3B3 /* GHSignInViewController.m */; };
81147184160BA97700878ACD /* GHTwitterConnectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 81147182160BA97700878ACD /* GHTwitterConnectViewController.m */; };
81147186160BB45F00878ACD /* GHTwitterConnectViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 81147188160BB45F00878ACD /* GHTwitterConnectViewController.xib */; };
+ 811471AB160CA8F300878ACD /* GHJoinNowViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 811471AA160CA8F300878ACD /* GHJoinNowViewController.m */; };
+ 811471AF160CA92600878ACD /* GHJoinNowViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 811471B1160CA92600878ACD /* GHJoinNowViewController.xib */; };
+ 811471B4160CB1C500878ACD /* GHFormTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 811471B3160CB1C400878ACD /* GHFormTextFieldCell.m */; };
811D71A1160A66B4007C806C /* gh-header-logo.png in Resources */ = {isa = PBXBuildFile; fileRef = 811D71A0160A66B4007C806C /* gh-header-logo.png */; };
811D71A3160A66BC007C806C /* gh-header-logo@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 811D71A2160A66BC007C806C /* gh-header-logo@2x.png */; };
811D71A5160A6875007C806C /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 811D719A160A626B007C806C /* Default@2x.png */; };
@@ -37,13 +40,13 @@
81963AE515E3E59E002C1BC6 /* GHServiceValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 81963AE315E3D95F002C1BC6 /* GHServiceValidator.m */; };
81963AE615E3EBF4002C1BC6 /* OA2AccessGrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 8196752515DD7B820056A806 /* OA2AccessGrant.m */; };
81963AE715E3EC29002C1BC6 /* NSDictionary+Helpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E42DE015ADE82F001FA72D /* NSDictionary+Helpers.m */; };
- 81963AE815E3F0B7002C1BC6 /* GHOAuth2Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A2492715DA948600C84332 /* GHOAuth2Controller.m */; };
+ 81963AE815E3F0B7002C1BC6 /* GHAuthController.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A2492715DA948600C84332 /* GHAuthController.m */; };
81963AE915E3F15B002C1BC6 /* GHURLPostRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8196752115DD388F0056A806 /* GHURLPostRequest.m */; };
81963AEA15E3F162002C1BC6 /* GHURLRequestParameters.m in Sources */ = {isa = PBXBuildFile; fileRef = 818BD9D315DCBF0C00BD7842 /* GHURLRequestParameters.m */; };
81963AEB15E3F16C002C1BC6 /* OA2SignInRequestParameters.m in Sources */ = {isa = PBXBuildFile; fileRef = 818BD9CC15DC949A00BD7842 /* OA2SignInRequestParameters.m */; };
81963AED15E3F1CA002C1BC6 /* GHKeychainManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 81963ADF15E2B88B002C1BC6 /* GHKeychainManager.m */; };
81963AEE15E3F1EE002C1BC6 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81E75F3911BE0D5800E6B283 /* Security.framework */; };
- 81963AF115E3F5DA002C1BC6 /* GHOauth2ControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 81963AF015E3F5DA002C1BC6 /* GHOauth2ControllerTests.m */; };
+ 81963AF115E3F5DA002C1BC6 /* GHAuthControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 81963AF015E3F5DA002C1BC6 /* GHAuthControllerTests.m */; };
8196752215DD388F0056A806 /* GHURLPostRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8196752115DD388F0056A806 /* GHURLPostRequest.m */; };
8196752615DD7B820056A806 /* OA2AccessGrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 8196752515DD7B820056A806 /* OA2AccessGrant.m */; };
8196752715DE7A290056A806 /* OA2AccessGrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 8196752515DD7B820056A806 /* OA2AccessGrant.m */; };
@@ -61,12 +64,14 @@
81A1BD3E15D5B44E0028A2D3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 81A1BD3C15D5B44E0028A2D3 /* InfoPlist.strings */; };
81A1BD4F15D5BA760028A2D3 /* UIColor+CustomColors.m in Sources */ = {isa = PBXBuildFile; fileRef = 81E42E0D15ADE82F001FA72D /* UIColor+CustomColors.m */; };
81A1BD5215D5BAE30028A2D3 /* UIColor_CustomColorsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A1BD5115D5BAE30028A2D3 /* UIColor_CustomColorsTests.m */; };
- 81A2491F15D9A6B400C84332 /* GHAuthorizeNavigationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 81A2492115D9A6B400C84332 /* GHAuthorizeNavigationViewController.xib */; };
81A2492315D9A6BF00C84332 /* GHSignInViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 81A2492515D9A6BF00C84332 /* GHSignInViewController.xib */; };
- 81A2492815DA948600C84332 /* GHOAuth2Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A2492715DA948600C84332 /* GHOAuth2Controller.m */; };
+ 81A2492815DA948600C84332 /* GHAuthController.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A2492715DA948600C84332 /* GHAuthController.m */; };
81A2B6781607B1F800F0840A /* GHEventSessionTweetDetailsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A2B6771607B1F800F0840A /* GHEventSessionTweetDetailsViewController.m */; };
81A2B67B1607BA3000F0840A /* twitter-logo.png in Resources */ = {isa = PBXBuildFile; fileRef = 81A2B6791607BA2D00F0840A /* twitter-logo.png */; };
81A2B67C1607BA3000F0840A /* twitter-logo@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 81A2B67A1607BA2E00F0840A /* twitter-logo@2x.png */; };
+ 81B5CBF1161029330032369C /* GHConnectionSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = 81FF4E7B1608D05F001B0ABC /* GHConnectionSettings.m */; };
+ 81B5CBF21610B1D90032369C /* GHSignUpForm.m in Sources */ = {isa = PBXBuildFile; fileRef = 8106BD6D160FA65C003968DB /* GHSignUpForm.m */; };
+ 81B5CBF51610B2E20032369C /* GHSignUpFormTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 81B5CBF41610B2E20032369C /* GHSignUpFormTests.m */; };
81C3139815E7DEF1004ADD53 /* GHKeychainManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 81C3139715E7DEF1004ADD53 /* GHKeychainManagerTests.m */; };
81C3139C15E82372004ADD53 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 81C3139B15E82371004ADD53 /* NSData+Base64.m */; };
81C3139D15E82372004ADD53 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 81C3139B15E82371004ADD53 /* NSData+Base64.m */; };
@@ -196,13 +201,19 @@
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
28860BE40F44EE6400985440 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
- 810FD30415D99E9200A9B3B3 /* GHAuthorizeNavigationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHAuthorizeNavigationViewController.h; sourceTree = "<group>"; };
- 810FD30515D99E9200A9B3B3 /* GHAuthorizeNavigationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHAuthorizeNavigationViewController.m; sourceTree = "<group>"; };
+ 8106BD6C160FA65C003968DB /* GHSignUpForm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHSignUpForm.h; sourceTree = "<group>"; };
+ 8106BD6D160FA65C003968DB /* GHSignUpForm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHSignUpForm.m; sourceTree = "<group>"; };
+ 8106BD6F160FB3FC003968DB /* GHAuthControllerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHAuthControllerDelegate.h; sourceTree = "<group>"; };
810FD30A15D9A0AE00A9B3B3 /* GHSignInViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHSignInViewController.h; sourceTree = "<group>"; };
810FD30B15D9A0AE00A9B3B3 /* GHSignInViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHSignInViewController.m; sourceTree = "<group>"; };
81147181160BA97700878ACD /* GHTwitterConnectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHTwitterConnectViewController.h; sourceTree = "<group>"; };
81147182160BA97700878ACD /* GHTwitterConnectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHTwitterConnectViewController.m; sourceTree = "<group>"; };
81147187160BB45F00878ACD /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/GHTwitterConnectViewController.xib; sourceTree = "<group>"; };
+ 811471A9160CA8F300878ACD /* GHJoinNowViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHJoinNowViewController.h; sourceTree = "<group>"; };
+ 811471AA160CA8F300878ACD /* GHJoinNowViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHJoinNowViewController.m; sourceTree = "<group>"; };
+ 811471B0160CA92600878ACD /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/GHJoinNowViewController.xib; sourceTree = "<group>"; };
+ 811471B2160CB1C400878ACD /* GHFormTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHFormTextFieldCell.h; sourceTree = "<group>"; };
+ 811471B3160CB1C400878ACD /* GHFormTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHFormTextFieldCell.m; sourceTree = "<group>"; };
811D7198160A614A007C806C /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
811D719A160A626B007C806C /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = "<group>"; };
811D71A0160A66B4007C806C /* gh-header-logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "gh-header-logo.png"; sourceTree = "<group>"; };
@@ -241,8 +252,8 @@
81963ADF15E2B88B002C1BC6 /* GHKeychainManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHKeychainManager.m; sourceTree = "<group>"; };
81963AE215E3D95F002C1BC6 /* GHServiceValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GHServiceValidator.h; path = ../GreenhouseLogicTests/GHServiceValidator.h; sourceTree = "<group>"; };
81963AE315E3D95F002C1BC6 /* GHServiceValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GHServiceValidator.m; path = ../GreenhouseLogicTests/GHServiceValidator.m; sourceTree = "<group>"; };
- 81963AEF15E3F5DA002C1BC6 /* GHOauth2ControllerTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHOauth2ControllerTests.h; sourceTree = "<group>"; };
- 81963AF015E3F5DA002C1BC6 /* GHOauth2ControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHOauth2ControllerTests.m; sourceTree = "<group>"; };
+ 81963AEF15E3F5DA002C1BC6 /* GHAuthControllerTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHAuthControllerTests.h; sourceTree = "<group>"; };
+ 81963AF015E3F5DA002C1BC6 /* GHAuthControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHAuthControllerTests.m; sourceTree = "<group>"; };
8196752015DD388F0056A806 /* GHURLPostRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHURLPostRequest.h; sourceTree = "<group>"; };
8196752115DD388F0056A806 /* GHURLPostRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHURLPostRequest.m; sourceTree = "<group>"; };
8196752415DD7B820056A806 /* OA2AccessGrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OA2AccessGrant.h; sourceTree = "<group>"; };
@@ -263,14 +274,15 @@
81A1BD4215D5B44E0028A2D3 /* GreenhouseApplicationTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GreenhouseApplicationTests-Prefix.pch"; sourceTree = "<group>"; };
81A1BD5015D5BAE30028A2D3 /* UIColor_CustomColorsTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIColor_CustomColorsTests.h; sourceTree = "<group>"; };
81A1BD5115D5BAE30028A2D3 /* UIColor_CustomColorsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIColor_CustomColorsTests.m; sourceTree = "<group>"; };
- 81A2492015D9A6B400C84332 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/GHAuthorizeNavigationViewController.xib; sourceTree = "<group>"; };
81A2492415D9A6BF00C84332 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/GHSignInViewController.xib; sourceTree = "<group>"; };
- 81A2492615DA948600C84332 /* GHOAuth2Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHOAuth2Controller.h; sourceTree = "<group>"; };
- 81A2492715DA948600C84332 /* GHOAuth2Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHOAuth2Controller.m; sourceTree = "<group>"; };
+ 81A2492615DA948600C84332 /* GHAuthController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHAuthController.h; sourceTree = "<group>"; };
+ 81A2492715DA948600C84332 /* GHAuthController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHAuthController.m; sourceTree = "<group>"; };
81A2B6761607B1F800F0840A /* GHEventSessionTweetDetailsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHEventSessionTweetDetailsViewController.h; sourceTree = "<group>"; };
81A2B6771607B1F800F0840A /* GHEventSessionTweetDetailsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHEventSessionTweetDetailsViewController.m; sourceTree = "<group>"; };
81A2B6791607BA2D00F0840A /* twitter-logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "twitter-logo.png"; sourceTree = "<group>"; };
81A2B67A1607BA2E00F0840A /* twitter-logo@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "twitter-logo@2x.png"; sourceTree = "<group>"; };
+ 81B5CBF31610B2E20032369C /* GHSignUpFormTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHSignUpFormTests.h; sourceTree = "<group>"; };
+ 81B5CBF41610B2E20032369C /* GHSignUpFormTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHSignUpFormTests.m; sourceTree = "<group>"; };
81C3139615E7DEF1004ADD53 /* GHKeychainManagerTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHKeychainManagerTests.h; sourceTree = "<group>"; };
81C3139715E7DEF1004ADD53 /* GHKeychainManagerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHKeychainManagerTests.m; sourceTree = "<group>"; };
81C3139A15E82371004ADD53 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Base64.h"; sourceTree = "<group>"; };
@@ -527,12 +539,12 @@
8124CE6C16078C55000D3D6E /* Authorization */ = {
isa = PBXGroup;
children = (
- 810FD30415D99E9200A9B3B3 /* GHAuthorizeNavigationViewController.h */,
- 810FD30515D99E9200A9B3B3 /* GHAuthorizeNavigationViewController.m */,
- 81A2492115D9A6B400C84332 /* GHAuthorizeNavigationViewController.xib */,
81E42D6715ADE82F001FA72D /* GHAuthorizeViewController.h */,
81E42D6815ADE82F001FA72D /* GHAuthorizeViewController.m */,
81E42D7915ADE82F001FA72D /* GHAuthorizeViewController.xib */,
+ 811471A9160CA8F300878ACD /* GHJoinNowViewController.h */,
+ 811471AA160CA8F300878ACD /* GHJoinNowViewController.m */,
+ 811471B1160CA92600878ACD /* GHJoinNowViewController.xib */,
810FD30A15D9A0AE00A9B3B3 /* GHSignInViewController.h */,
810FD30B15D9A0AE00A9B3B3 /* GHSignInViewController.m */,
81A2492515D9A6BF00C84332 /* GHSignInViewController.xib */,
@@ -549,6 +561,8 @@
815D0A431604F31F002786A4 /* EventSession.m */,
81CFAA5E15F9077500661D68 /* EventSessionLeader.h */,
81CFAA5F15F9077800661D68 /* EventSessionLeader.m */,
+ 8106BD6C160FA65C003968DB /* GHSignUpForm.h */,
+ 8106BD6D160FA65C003968DB /* GHSignUpForm.m */,
81CFAA5515F7F31500661D68 /* Profile.h */,
81CFAA5615F7F31600661D68 /* Profile.m */,
815D0A481604F372002786A4 /* Tweet.h */,
@@ -608,6 +622,7 @@
children = (
8196752915DE7C320056A806 /* Categories */,
8196752A15DE7C4A0056A806 /* Controllers */,
+ 81B5CBF61610BACC0032369C /* Models */,
81A1BD1D15D5AF9D0028A2D3 /* Supporting Files */,
);
path = GreenhouseLogicTests;
@@ -628,8 +643,8 @@
children = (
81C3139615E7DEF1004ADD53 /* GHKeychainManagerTests.h */,
81C3139715E7DEF1004ADD53 /* GHKeychainManagerTests.m */,
- 81963AEF15E3F5DA002C1BC6 /* GHOauth2ControllerTests.h */,
- 81963AF015E3F5DA002C1BC6 /* GHOauth2ControllerTests.m */,
+ 81963AEF15E3F5DA002C1BC6 /* GHAuthControllerTests.h */,
+ 81963AF015E3F5DA002C1BC6 /* GHAuthControllerTests.m */,
81963AE215E3D95F002C1BC6 /* GHServiceValidator.h */,
81963AE315E3D95F002C1BC6 /* GHServiceValidator.m */,
81A1BD3A15D5B44E0028A2D3 /* Supporting Files */,
@@ -647,6 +662,15 @@
name = "Supporting Files";
sourceTree = "<group>";
};
+ 81B5CBF61610BACC0032369C /* Models */ = {
+ isa = PBXGroup;
+ children = (
+ 81B5CBF31610B2E20032369C /* GHSignUpFormTests.h */,
+ 81B5CBF41610B2E20032369C /* GHSignUpFormTests.m */,
+ );
+ name = Models;
+ sourceTree = "<group>";
+ };
81CD36F816023F1900FFFCEA /* Events */ = {
isa = PBXGroup;
children = (
@@ -840,6 +864,8 @@
81E42D6F15ADE82F001FA72D /* GHCustomTabBar.m */,
81E42D7015ADE82F001FA72D /* GHCustomToolbar.h */,
81E42D7115ADE82F001FA72D /* GHCustomToolbar.m */,
+ 811471B2160CB1C400878ACD /* GHFormTextFieldCell.h */,
+ 811471B3160CB1C400878ACD /* GHFormTextFieldCell.m */,
81E42E0215ADE82F001FA72D /* GHTweetTableViewCell.h */,
81E42E0315ADE82F001FA72D /* GHTweetTableViewCell.m */,
81E42E1215ADE82F001FA72D /* GHVenueAnnotation.h */,
@@ -878,6 +904,9 @@
81E42ED515AF4160001FA72D /* Controllers */ = {
isa = PBXGroup;
children = (
+ 81A2492615DA948600C84332 /* GHAuthController.h */,
+ 81A2492715DA948600C84332 /* GHAuthController.m */,
+ 8106BD6F160FB3FC003968DB /* GHAuthControllerDelegate.h */,
81E42DE315ADE82F001FA72D /* GHBaseController.h */,
81E42DE415ADE82F001FA72D /* GHBaseController.m */,
81E42DA115ADE82F001FA72D /* GHEventController.h */,
@@ -892,8 +921,6 @@
818F217015FD9A8F0003B72C /* GHEventSessionsFavoritesDelegate.h */,
818F216D15FD960A0003B72C /* GHEventSessionUpdateFavoriteDelegate.h */,
81E42DDB15ADE82F001FA72D /* GHLocationManagerDelegate.h */,
- 81A2492615DA948600C84332 /* GHOAuth2Controller.h */,
- 81A2492715DA948600C84332 /* GHOAuth2Controller.m */,
81E42DE915ADE82F001FA72D /* GHProfileController.h */,
81E42DEA15ADE82F001FA72D /* GHProfileController.m */,
81E42DEB15ADE82F001FA72D /* GHProfileControllerDelegate.h */,
@@ -1112,7 +1139,6 @@
81E42E7215ADE82F001FA72D /* tab-events@2x.png in Resources */,
81E42E7315ADE82F001FA72D /* tab-info.png in Resources */,
81E42E7415ADE82F001FA72D /* tab-info@2x.png in Resources */,
- 81A2491F15D9A6B400C84332 /* GHAuthorizeNavigationViewController.xib in Resources */,
81A2492315D9A6BF00C84332 /* GHSignInViewController.xib in Resources */,
817D817015FE831900C7A351 /* GHEventSessionsScheduleViewController.xib in Resources */,
81A2B67B1607BA3000F0840A /* twitter-logo.png in Resources */,
@@ -1126,6 +1152,7 @@
819DBEBE160AD574002A6081 /* GHEventSessionDetailsContent.html in Resources */,
819DBEC1160AE378002A6081 /* GHVenueDetailsContent.html in Resources */,
81147186160BB45F00878ACD /* GHTwitterConnectViewController.xib in Resources */,
+ 811471AF160CA92600878ACD /* GHJoinNowViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1228,9 +1255,8 @@
81E42E8015ADE82F001FA72D /* GHVenueAnnotation.m in Sources */,
81E42E8115ADE82F001FA72D /* GHVenueDetailsViewController.m in Sources */,
81E42E8315ADE82F001FA72D /* GHWebImageView.m in Sources */,
- 810FD30715D99E9200A9B3B3 /* GHAuthorizeNavigationViewController.m in Sources */,
810FD30D15D9A0AE00A9B3B3 /* GHSignInViewController.m in Sources */,
- 81A2492815DA948600C84332 /* GHOAuth2Controller.m in Sources */,
+ 81A2492815DA948600C84332 /* GHAuthController.m in Sources */,
818BD9CD15DC949A00BD7842 /* OA2SignInRequestParameters.m in Sources */,
818BD9D415DCBF0C00BD7842 /* GHURLRequestParameters.m in Sources */,
8196752215DD388F0056A806 /* GHURLPostRequest.m in Sources */,
@@ -1258,6 +1284,9 @@
81A2B6781607B1F800F0840A /* GHEventSessionTweetDetailsViewController.m in Sources */,
81FF4E7C1608D05F001B0ABC /* GHConnectionSettings.m in Sources */,
81147184160BA97700878ACD /* GHTwitterConnectViewController.m in Sources */,
+ 811471AB160CA8F300878ACD /* GHJoinNowViewController.m in Sources */,
+ 811471B4160CB1C500878ACD /* GHFormTextFieldCell.m in Sources */,
+ 8106BD6E160FA65C003968DB /* GHSignUpForm.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1271,6 +1300,8 @@
818C666215D95C6600594B97 /* NSDictionary+Helpers.m in Sources */,
8196752715DE7A290056A806 /* OA2AccessGrant.m in Sources */,
8196752E15DE7C850056A806 /* OA2AccessGrantTests.m in Sources */,
+ 81B5CBF21610B1D90032369C /* GHSignUpForm.m in Sources */,
+ 81B5CBF51610B2E20032369C /* GHSignUpFormTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1281,17 +1312,18 @@
81963AE515E3E59E002C1BC6 /* GHServiceValidator.m in Sources */,
81963AE615E3EBF4002C1BC6 /* OA2AccessGrant.m in Sources */,
81963AE715E3EC29002C1BC6 /* NSDictionary+Helpers.m in Sources */,
- 81963AE815E3F0B7002C1BC6 /* GHOAuth2Controller.m in Sources */,
+ 81963AE815E3F0B7002C1BC6 /* GHAuthController.m in Sources */,
81963AE915E3F15B002C1BC6 /* GHURLPostRequest.m in Sources */,
81963AEA15E3F162002C1BC6 /* GHURLRequestParameters.m in Sources */,
81963AEB15E3F16C002C1BC6 /* OA2SignInRequestParameters.m in Sources */,
81963AED15E3F1CA002C1BC6 /* GHKeychainManager.m in Sources */,
- 81963AF115E3F5DA002C1BC6 /* GHOauth2ControllerTests.m in Sources */,
+ 81963AF115E3F5DA002C1BC6 /* GHAuthControllerTests.m in Sources */,
81C3139815E7DEF1004ADD53 /* GHKeychainManagerTests.m in Sources */,
81C3139D15E82372004ADD53 /* NSData+Base64.m in Sources */,
81C313A415EBE824004ADD53 /* OA2AuthorizedRequest.m in Sources */,
81C313A515EBE8B2004ADD53 /* GHURLRequest.m in Sources */,
81C313A915EBEA1A004ADD53 /* OA2SignInRequest.m in Sources */,
+ 81B5CBF1161029330032369C /* GHConnectionSettings.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1314,6 +1346,14 @@
name = GHTwitterConnectViewController.xib;
sourceTree = "<group>";
};
+ 811471B1160CA92600878ACD /* GHJoinNowViewController.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 811471B0160CA92600878ACD /* en */,
+ );
+ name = GHJoinNowViewController.xib;
+ sourceTree = "<group>";
+ };
817D817215FE831900C7A351 /* GHEventSessionsScheduleViewController.xib */ = {
isa = PBXVariantGroup;
children = (
@@ -1338,14 +1378,6 @@
name = InfoPlist.strings;
sourceTree = "<group>";
};
- 81A2492115D9A6B400C84332 /* GHAuthorizeNavigationViewController.xib */ = {
- isa = PBXVariantGroup;
- children = (
- 81A2492015D9A6B400C84332 /* en */,
- );
- name = GHAuthorizeNavigationViewController.xib;
- sourceTree = "<group>";
- };
81A2492515D9A6BF00C84332 /* GHSignInViewController.xib */ = {
isa = PBXVariantGroup;
children = (
View
14 Greenhouse/GHOAuth2Controller.h → Greenhouse/GHAuthController.h
@@ -14,23 +14,27 @@
// limitations under the License.
//
//
-// GHOAuth2Controller.h
+// GHAuthController.h
// Greenhouse
//
// Created by Roy Clarkson on 8/14/12.
//
#import <Foundation/Foundation.h>
-#import "OA2AccessGrant.h"
+#import "GHAuthControllerDelegate.h"
-@interface GHOAuth2Controller : NSObject
+@class OA2AccessGrant;
+@class GHSignUpForm;
-+ (GHOAuth2Controller *)sharedInstance;
+@interface GHAuthController : NSObject
++ (GHAuthController *)sharedInstance;
+ (BOOL)isAuthorized;
-- (NSURLRequest *)signInRequestWithUsername:(NSString *)username password:(NSString *)password;
+ (BOOL)storeAccessGrant:(OA2AccessGrant *)accessGrant;
+ (OA2AccessGrant *)fetchAccessGrant;
+ (BOOL)deleteAccessGrant;
+- (void)sendRequestToSignIn:(NSString *)username password:(NSString *)password delegate:(id<GHAuthControllerDelegate>)delegate;
+- (void)sendRequestToSignUp:(GHSignUpForm *)signUpForm delegate:(id<GHAuthControllerDelegate>)delegate;
+
@end
View
239 Greenhouse/GHAuthController.m
@@ -0,0 +1,239 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHAuthController.m
+// Greenhouse
+//
+// Created by Roy Clarkson on 8/14/12.
+//
+
+#define KEYCHAIN_SERVICE_NAME @"Greenhouse"
+#define KEYCHAIN_ACCOUNT_NAME @"OAuth2"
+
+#import "GHAuthController.h"
+#import "OA2AccessGrant.h"
+#import "GHSignUpForm.h"
+#import "OA2SignInRequestParameters.h"
+#import "GHURLPostRequest.h"
+#import "GHKeychainManager.h"
+#import "GHConnectionSettings.h"
+
+@implementation GHAuthController
+
+
+#pragma mark -
+#pragma mark Static methods
+
+// Use this class method to obtain the shared instance of the class.
++ (GHAuthController *)sharedInstance
+{
+ static GHAuthController *_sharedInstance = nil;
+ static dispatch_once_t predicate;
+ dispatch_once(&predicate, ^{
+ _sharedInstance = [[GHAuthController alloc] init];
+ });
+ return _sharedInstance;
+}
+
++ (BOOL)isAuthorized
+{
+ OA2AccessGrant *accessGrant = [self fetchAccessGrant];
+ return (accessGrant != nil);
+}
+
++ (BOOL)storeAccessGrant:(OA2AccessGrant *)accessGrant
+{
+ OSStatus status = [[GHKeychainManager sharedInstance] storePassword:[accessGrant dataValue] service:KEYCHAIN_SERVICE_NAME account:KEYCHAIN_ACCOUNT_NAME];
+ return (status == errSecSuccess);
+}
+
++ (OA2AccessGrant *)fetchAccessGrant
+{
+ NSData *passwordData;
+ OSStatus status = [[GHKeychainManager sharedInstance] fetchPassword:&passwordData service:KEYCHAIN_SERVICE_NAME account:KEYCHAIN_ACCOUNT_NAME];
+ if (status == errSecSuccess && passwordData)
+ {
+ NSError *error;
+ OA2AccessGrant *accessGrant = [[OA2AccessGrant alloc] initWithData:passwordData error:&error];
+ return accessGrant;
+ }
+ return nil;
+}
+
++ (BOOL)deleteAccessGrant
+{
+ OSStatus status = [[GHKeychainManager sharedInstance] deletePasswordWithService:KEYCHAIN_SERVICE_NAME account:KEYCHAIN_ACCOUNT_NAME];
+ return (status == errSecSuccess);
+}
+
+
+#pragma mark -
+#pragma mark Instance methods
+
+- (void)sendRequestToSignIn:(NSString *)username password:(NSString *)password delegate:(id<GHAuthControllerDelegate>)delegate
+{
+ OA2SignInRequestParameters *parameters = [[OA2SignInRequestParameters alloc] initWithUsername:username password:password];
+ NSURL *url = [GHConnectionSettings urlWithFormat:@"/oauth/token"];
+ NSURLRequest *request = [[GHURLPostRequest alloc] initWithURL:url parameters:parameters];
+ DLog(@"%@", request);
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
+ [NSURLConnection sendAsynchronousRequest:request
+ queue:[[NSOperationQueue alloc] init]
+ completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
+ {
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
+ NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
+ if (statusCode == 200 && data.length > 0 && error == nil)
+ {
+ DLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
+ NSError *errorInternal;
+ OA2AccessGrant *accessGrant = [[OA2AccessGrant alloc] initWithData:data error:&errorInternal];
+ if (!errorInternal)
+ {
+ [GHAuthController storeAccessGrant:accessGrant];
+ }
+ else
+ {
+ DLog(@"error parsing access grant: %@", [errorInternal localizedDescription]);
+ }
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ [delegate authRequestDidSucceed];
+ });
+ }
+ else if (error)
+ {
+ DLog(@"%d - %@", [error code], [error localizedDescription]);
+ NSString *msg;
+ switch ([error code]) {
+ case NSURLErrorUserCancelledAuthentication:
+ msg = @"Your email or password was entered incorrectly.";
+ break;
+ case NSURLErrorCannotConnectToHost:
+ msg = @"The server is unavailable. Please try again in a few minutes.";
+ break;
+ default:
+ msg = @"A problem occurred with the network connection. Please try again in a few minutes.";
+ break;
+ }
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
+ message:msg
+ delegate:nil
+ cancelButtonTitle:@"OK"
+ otherButtonTitles:nil];
+ [alert show];
+ [delegate authRequestDidFailWithError:error];
+ });
+ }
+ else if (statusCode != 200)
+ {
+ DLog(@"HTTP Status Code: %d", statusCode);
+ NSString *msg;
+ switch (statusCode) {
+ default:
+ msg = @"You cannot be signed in.";
+ break;
+ }
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
+ message:msg
+ delegate:nil
+ cancelButtonTitle:@"OK"
+ otherButtonTitles:nil];
+ [alertView show];
+ [delegate authRequestDidFailWithError:error];
+ });
+ }
+ }];
+}
+
+- (void)sendRequestToSignUp:(GHSignUpForm *)signUpForm delegate:(id<GHAuthControllerDelegate>)delegate
+{
+ NSURL *url = [GHConnectionSettings urlWithFormat:@"/signup"];
+ NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[signUpForm dictionaryValue] options:0 error:nil];
+ DLog(@"%@", [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]);
+ NSString *postLength = [NSString stringWithFormat:@"%d", [jsonData length]];
+ [request setHTTPMethod:@"POST"];
+ [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
+ [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
+ [request setHTTPBody:jsonData];
+ DLog(@"%@", request);
+
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
+ [NSURLConnection sendAsynchronousRequest:request
+ queue:[[NSOperationQueue alloc] init]
+ completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
+ {
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
+ NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
+ DLog(@"status code: %d", statusCode);
+ DLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
+ if (statusCode == 201 && data.length > 0 && error == nil)
+ {
+ // account successfully created, so now sign in
+ [self sendRequestToSignIn:signUpForm.email password:signUpForm.password delegate:delegate];
+ }
+ else if (statusCode == 400 && data.length > 0)
+ {
+ // errors creating account
+
+ NSError *errorInternal;
+ NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&errorInternal];
+ if (!errorInternal)
+ {
+ NSString *title = [dictionary stringForKey:@"message"];
+ NSArray *validationErrors = [dictionary objectForKey:@"errors"];
+ NSMutableArray *messages = [[NSMutableArray alloc] init];
+ [validationErrors enumerateObjectsUsingBlock:^(NSDictionary *validationError, NSUInteger idx, BOOL *stop) {
+ [messages addObject:[[NSString alloc] initWithFormat:@"- %@ %@",
+ [validationError stringForKey:@"field"],
+ [validationError stringForKey:@"message"]]];
+ }];
+ NSString *message = [messages componentsJoinedByString:@"\n"];
+
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
+ message:message
+ delegate:@""
+ cancelButtonTitle:@"OK"
+ otherButtonTitles:nil];
+ [alert show];
+ [delegate authRequestDidFailWithError:error];
+ });
+ }
+ else
+ {
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ [delegate authRequestDidFailWithError:error];
+ });
+ }
+ }
+ else
+ {
+ if (error)
+ {
+ DLog(@"%d - %@", [error code], [error localizedDescription]);
+ }
+
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ [delegate authRequestDidFailWithError:error];
+ });
+ }
+ }];
+}
+
+@end
View
30 Greenhouse/GHAuthControllerDelegate.h
@@ -0,0 +1,30 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHAuthControllerDelegate.h
+// Greenhouse
+//
+// Created by Roy Clarkson on 9/23/12.
+//
+
+#import <Foundation/Foundation.h>
+
+@protocol GHAuthControllerDelegate <NSObject>
+
+- (void)authRequestDidSucceed;
+- (void)authRequestDidFailWithError:(NSError *)error;
+
+@end
View
60 Greenhouse/GHAuthorizeNavigationViewController.m
@@ -1,60 +0,0 @@
-//
-// Copyright 2012 the original author or authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//
-// GHAuthorizeNavigationViewController.m
-// Greenhouse
-//
-// Created by Roy Clarkson on 7/30/12.
-//
-
-#import "GHAuthorizeNavigationViewController.h"
-
-@interface GHAuthorizeNavigationViewController ()
-
-@end
-
-@implementation GHAuthorizeNavigationViewController
-
-@synthesize navigationController;
-
-
-#pragma mark -
-#pragma mark UIViewController methods
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
-
- // correct the layout of the subview
- navigationController.view.frame = self.view.bounds;
-
- // add the home screen view
- [self.view addSubview:navigationController.view];
-}
-
-- (void)didReceiveMemoryWarning
-{
- [super didReceiveMemoryWarning];
-}
-
-- (void)viewDidUnload
-{
- [super viewDidUnload];
-
- self.navigationController = nil;
-}
-
-@end
View
6 Greenhouse/GHAuthorizeViewController.h
@@ -21,12 +21,16 @@
//
#import <UIKit/UIKit.h>
-#import "GHSignInViewController.h"
+
+@class GHSignInViewController;
+@class GHJoinNowViewController;
@interface GHAuthorizeViewController : UIViewController
@property (nonatomic, strong) IBOutlet GHSignInViewController *signInViewController;
+@property (nonatomic, strong) IBOutlet GHJoinNowViewController *joinNowViewController;
- (IBAction)actionSignIn:(id)sender;
+- (IBAction)actionJoinNow:(id)sender;
@end
View
29 Greenhouse/GHAuthorizeViewController.m
@@ -21,16 +21,28 @@
//
#import "GHAuthorizeViewController.h"
+#import "GHSignInViewController.h"
+#import "GHJoinNowViewController.h"
@implementation GHAuthorizeViewController
@synthesize signInViewController;
+@synthesize joinNowViewController;
+
+
+#pragma mark -
+#pragma mark Public Instance methods
- (IBAction)actionSignIn:(id)sender
{
[self.navigationController pushViewController:signInViewController animated:YES];
}
+- (IBAction)actionJoinNow:(id)sender
+{
+ [self.navigationController pushViewController:joinNowViewController animated:YES];
+}
+
#pragma mark -
#pragma mark UIViewController methods
@@ -38,20 +50,29 @@ - (IBAction)actionSignIn:(id)sender
- (void)viewDidLoad
{
[super viewDidLoad];
+ DLog(@"");
- [self.navigationController setNavigationBarHidden:YES];
+ self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Home"
+ style:UIBarButtonItemStyleBordered
+ target:nil
+ action:nil];
}
-- (void)didReceiveMemoryWarning
+- (void)viewWillAppear:(BOOL)animated
{
- [super didReceiveMemoryWarning];
+ [super viewWillAppear:animated];
+ DLog(@"");
+
+ [self.navigationController setNavigationBarHidden:YES];
}
-- (void)viewDidUnload
+- (void)viewDidUnload
{
[super viewDidUnload];
+ DLog(@"");
self.signInViewController = nil;
+ self.joinNowViewController = nil;
}
@end
View
5 Greenhouse/GHAuthorizedRequest.m
@@ -21,13 +21,14 @@
//
#import "GHAuthorizedRequest.h"
-#import "GHOAuth2Controller.h"
+#import "GHAuthController.h"
+#import "OA2AccessGrant.h"
@implementation GHAuthorizedRequest
- (id)initWithURL:(NSURL *)URL
{
- OA2AccessGrant *accessGrant = [GHOAuth2Controller fetchAccessGrant];
+ OA2AccessGrant *accessGrant = [GHAuthController fetchAccessGrant];
return [super initWithURL:URL accessToken:accessGrant.accessToken];
}
View
9 Greenhouse/GHEventsMainViewController.m
@@ -155,11 +155,10 @@ - (void)viewDidLoad
self.title = @"Upcoming Events";
self.eventDetailsViewController = [[GHEventDetailsViewController alloc] initWithNibName:nil bundle:nil];
- self.navigationItem.backBarButtonItem =
- [[UIBarButtonItem alloc] initWithTitle:@"Events"
- style:UIBarButtonItemStyleBordered
- target:nil
- action:nil];
+ self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Events"
+ style:UIBarButtonItemStyleBordered
+ target:nil
+ action:nil];
}
- (void)viewWillAppear:(BOOL)animated
View
9 Greenhouse/GHAuthorizeNavigationViewController.h → Greenhouse/GHFormTextFieldCell.h
@@ -14,16 +14,17 @@
// limitations under the License.
//
//
-// GHAuthorizeNavigationViewController.h
+// GHFormTextFieldCell.h
// Greenhouse
//
-// Created by Roy Clarkson on 7/30/12.
+// Created by Roy Clarkson on 8/2/12.
//
#import <UIKit/UIKit.h>
-@interface GHAuthorizeNavigationViewController : UIViewController <UINavigationControllerDelegate>
+@interface GHFormTextFieldCell : UITableViewCell
-@property (nonatomic, strong) IBOutlet UINavigationController *navigationController;
+@property (nonatomic, retain) IBOutlet UILabel *formLabel;
+@property (nonatomic, retain) IBOutlet UITextField *formTextField;
@end
View
30 Greenhouse/GHFormTextFieldCell.m
@@ -0,0 +1,30 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHFormTextFieldCell.m
+// Greenhouse
+//
+// Created by Roy Clarkson on 8/2/12.
+//
+
+#import "GHFormTextFieldCell.h"
+
+@implementation GHFormTextFieldCell
+
+@synthesize formLabel;
+@synthesize formTextField;
+
+@end
View
58 Greenhouse/GHJoinNowViewController.h
@@ -0,0 +1,58 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHJoinNowViewController.h
+// Greenhouse
+//
+// Created by Roy Clarkson on 8/1/12.
+//
+
+#import <UIKit/UIKit.h>
+#import "GHAuthControllerDelegate.h"
+
+@class GHFormTextFieldCell;
+
+@interface GHJoinNowViewController : UIViewController <UIScrollViewDelegate, UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate, UIPickerViewDelegate, UIPickerViewDataSource, GHAuthControllerDelegate>
+
+@property (nonatomic, strong) IBOutlet UIView *containerView;
+@property (nonatomic, strong) IBOutlet UITableView *signUpForm;
+@property (nonatomic, strong) IBOutlet GHFormTextFieldCell *firstNameCell;
+@property (nonatomic, strong) IBOutlet GHFormTextFieldCell *lastNameCell;
+@property (nonatomic, strong) IBOutlet GHFormTextFieldCell *emailCell;
+@property (nonatomic, strong) IBOutlet GHFormTextFieldCell *confirmEmailCell;
+@property (nonatomic, strong) IBOutlet GHFormTextFieldCell *passwordCell;
+@property (nonatomic, strong) IBOutlet GHFormTextFieldCell *genderCell;
+@property (nonatomic, strong) IBOutlet GHFormTextFieldCell *birthdayCell;
+@property (nonatomic, strong) IBOutlet UIToolbar *formToolbar;
+@property (nonatomic, strong) IBOutletCollection(UITextField) NSArray *formTextFields;
+@property (nonatomic, strong) IBOutlet UITextField *firstNameTextField;
+@property (nonatomic, strong) IBOutlet UITextField *lastNameTextField;
+@property (nonatomic, strong) IBOutlet UITextField *emailTextField;
+@property (nonatomic, strong) IBOutlet UITextField *confirmEmailTextField;
+@property (nonatomic, strong) IBOutlet UITextField *passwordTextField;
+@property (nonatomic, strong) IBOutlet UITextField *genderTextField;
+@property (nonatomic, strong) IBOutlet UITextField *birthdayTextField;
+@property (nonatomic, strong) IBOutlet UIPickerView *genderPickerView;
+@property (nonatomic, strong) IBOutlet UIDatePicker *birthdayPickerView;
+
+- (IBAction)actionCancel:(id)sender;
+- (IBAction)actionSubmit:(id)sender;
+- (IBAction)actionPrevious:(id)sender;
+- (IBAction)actionNext:(id)sender;
+- (IBAction)actionDone:(id)sender;
+- (IBAction)actionBirthdayValueChanged:(id)sender;
+
+@end
View
525 Greenhouse/GHJoinNowViewController.m
@@ -0,0 +1,525 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHJoinNowViewController.m
+// Greenhouse
+//
+// Created by Roy Clarkson on 8/1/12.
+//
+
+#define TOOLBAR_ORIGIN_OFFSET 200
+
+#import "GHJoinNowViewController.h"
+#import "GHFormTextFieldCell.h"
+#import "GHAuthController.h"
+#import "GHSignUpForm.h"
+#import "GHActivityAlertView.h"
+
+@interface GHJoinNowViewController ()
+{
+ BOOL keyboardIsDisplaying;
+ NSInteger selectedFormField;
+}
+
+@property (nonatomic, strong) NSArray *formCells;
+@property (nonatomic, strong) NSArray *genderValues;
+@property (nonatomic, strong) GHActivityAlertView *activityView;
+
+- (void)signUp;
+- (BOOL)validateFormData:(GHSignUpForm *)form;
+- (void)addNotificationCenterObservers;
+- (void)removeNotificationCenterObservers;
+- (void)keyboardWillShow:(NSNotification *)notification;
+- (void)keyboardWillHide:(NSNotification *)notification;
+- (NSTimeInterval)keyboardAnimationDurationForNotification:(NSNotification*)notification;
+
+@end
+
+@implementation GHJoinNowViewController
+
+@synthesize formCells;
+@synthesize genderValues;
+@synthesize activityView;
+@synthesize containerView;
+@synthesize signUpForm;
+@synthesize firstNameCell;
+@synthesize lastNameCell;
+@synthesize emailCell;
+@synthesize confirmEmailCell;
+@synthesize passwordCell;
+@synthesize genderCell;
+@synthesize birthdayCell;
+@synthesize formToolbar;
+@synthesize formTextFields;
+@synthesize firstNameTextField;
+@synthesize lastNameTextField;
+@synthesize emailTextField;
+@synthesize confirmEmailTextField;
+@synthesize passwordTextField;
+@synthesize genderTextField;
+@synthesize birthdayTextField;
+@synthesize genderPickerView;
+@synthesize birthdayPickerView;
+
+
+#pragma mark -
+#pragma mark Public methods
+
+- (IBAction)actionCancel:(id)sender
+{
+ [self resetTextFields];
+ [self.navigationController popToRootViewControllerAnimated:YES];
+}
+
+- (IBAction)actionSubmit:(id)sender
+{
+ [self signUp];
+}
+
+- (IBAction)actionPrevious:(id)sender
+{
+ [formCells enumerateObjectsUsingBlock:^(GHFormTextFieldCell *cell, NSUInteger idx, BOOL *stop) {
+ if (cell.formTextField.isFirstResponder)
+ {
+ NSUInteger prevIdx = idx - 1;
+ if (idx > 0)
+ {
+ GHFormTextFieldCell *cell = [self.formCells objectAtIndex:prevIdx];
+ [cell.formTextField becomeFirstResponder];
+ }
+ *stop = YES;
+ }
+ }];
+}
+
+- (IBAction)actionNext:(id)sender
+{
+ [formCells enumerateObjectsUsingBlock:^(GHFormTextFieldCell *cell, NSUInteger idx, BOOL *stop) {
+ if (cell.formTextField.isFirstResponder)
+ {
+ NSUInteger nextIdx = idx + 1;
+ if (idx < formCells.count-1)
+ {
+ GHFormTextFieldCell *cell = [self.formCells objectAtIndex:nextIdx];
+ [cell.formTextField becomeFirstResponder];
+ }
+ *stop = YES;
+ }
+ }];
+}
+
+- (IBAction)actionDone:(id)sender
+{
+ [self.view endEditing:YES];
+}
+
+- (IBAction)actionBirthdayValueChanged:(id)sender
+{
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+ [dateFormatter setDateFormat:@"dd MMMM, yyyy"];
+ birthdayTextField.text = [dateFormatter stringFromDate:birthdayPickerView.date];
+}
+
+
+#pragma mark -
+#pragma mark Private methods
+
+- (void)resetTextFields
+{
+ [formTextFields enumerateObjectsUsingBlock:^(UITextField *field, NSUInteger idx, BOOL *stop) {
+ field.text = nil;
+ }];
+ [self.view endEditing:YES];
+ CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
+ [(UIScrollView *)self.view scrollRectToVisible:rect animated:NO];
+}
+
+- (void)signUp
+{
+ GHSignUpForm *form = [[GHSignUpForm alloc]
+ initWithFirstName:[firstNameTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]
+ lastName:[lastNameTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]
+ email:[emailTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]
+ confirmEmail:[confirmEmailTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]
+ password:[passwordTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]
+ gender:[genderValues objectAtIndex:[genderPickerView selectedRowInComponent:0]]
+ birthday:birthdayPickerView.date];
+
+ if (![self validateFormData:form])
+ {
+ return;
+ }
+
+ self.activityView = [[GHActivityAlertView alloc] initWithActivityMessage:@"Creating account..."];
+ [activityView startAnimating];
+ [[GHAuthController sharedInstance] sendRequestToSignUp:form delegate:self];
+}
+
+- (BOOL)validateFormData:(GHSignUpForm *)form
+{
+ NSString *firstNameValue = [firstNameTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+ NSString *lastNameValue = [lastNameTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+ NSString *emailValue = [emailTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+ NSString *confirmEmailValue = [confirmEmailTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+ NSString *passwordValue = [passwordTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+
+ NSMutableArray *errors = [NSMutableArray array];
+ if ([firstNameValue isEqualToString:@""])
+ [errors addObject:@"First Name is required"];
+
+ if ([lastNameValue isEqualToString:@""])
+ [errors addObject:@"Last Name is required"];
+
+ if ([emailValue isEqualToString:@""])
+ [errors addObject:@"Email is required"];
+
+ if (![emailValue isEqualToString:confirmEmailValue])
+ [errors addObject:@"Emails do not match"];
+
+ if (passwordValue.length < 6)
+ [errors addObject:@"Password must be at least 6 characters"];
+
+ NSInteger row = [genderPickerView selectedRowInComponent:0];
+ if (row == 0)
+ [errors addObject:@"Gender is required"];
+
+ if (errors.count > 0)
+ {
+ NSString *message = [errors componentsJoinedByString:@"\n"];
+ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Missing Information"
+ message:message
+ delegate:self
+ cancelButtonTitle:@"OK"
+ otherButtonTitles:nil];
+ [alertView show];
+ return NO;
+ }
+ else
+ {
+ return YES;
+ }
+}
+
+- (void)addNotificationCenterObservers
+{
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillShow:)
+ name:UIKeyboardWillShowNotification
+ object:self.view.window];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(keyboardWillHide:)
+ name:UIKeyboardWillHideNotification
+ object:self.view.window];
+}
+
+- (void)removeNotificationCenterObservers
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:UIKeyboardWillShowNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:UIKeyboardWillHideNotification
+ object:nil];
+}
+
+- (void)keyboardWillShow:(NSNotification *)notification
+{
+ DLog(@"");
+ if (keyboardIsDisplaying)
+ {
+ return;
+ }
+
+ CGRect toolbarFrame = self.formToolbar.frame;
+ NSInteger viewHeight = self.view.frame.size.height;
+ NSInteger scrollViewOffset = ((UIScrollView *)self.view).contentOffset.y;
+ NSInteger keyboardHeight = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size.height;
+ NSInteger toolbarHeight = toolbarFrame.size.height;
+
+ // position the toolbar when the keyboard displays
+ toolbarFrame.origin.y = scrollViewOffset + (viewHeight - (keyboardHeight + toolbarHeight));
+
+ // animate the toolbar movement
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationDuration:[self keyboardAnimationDurationForNotification:notification]];
+ [self.view bringSubviewToFront:formToolbar];
+ self.formToolbar.frame = toolbarFrame;
+ [UIView commitAnimations];
+
+ keyboardIsDisplaying = YES;
+}
+
+- (void)keyboardWillHide:(NSNotification *)notification
+{
+ DLog(@"");
+
+ // hide the toolbar when the keyboard hides
+ CGRect toolbarFrame = self.formToolbar.frame;
+ toolbarFrame.origin.y = self.containerView.frame.size.height + TOOLBAR_ORIGIN_OFFSET;
+
+ // animate the toolbar movement
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationDuration:[self keyboardAnimationDurationForNotification:notification]];
+ self.formToolbar.frame = toolbarFrame;
+ [self.view sendSubviewToBack:formToolbar];
+ [UIView commitAnimations];
+
+ keyboardIsDisplaying = NO;
+}
+
+- (NSTimeInterval)keyboardAnimationDurationForNotification:(NSNotification*)notification
+{
+ NSDictionary* info = [notification userInfo];
+ NSValue* value = [info objectForKey:UIKeyboardAnimationDurationUserInfoKey];
+ NSTimeInterval duration = 0;
+ [value getValue:&duration];
+ return duration;
+}
+
+
+#pragma mark -
+#pragma mark GHAuthControllerDelegate methods
+
+- (void)authRequestDidSucceed
+{
+ [activityView stopAnimating];
+ self.activityView = nil;
+ [self resetTextFields];
+ [(GreenhouseAppDelegate *)[[UIApplication sharedApplication] delegate] showTabBarController];
+}
+
+- (void)authRequestDidFailWithError:(NSError *)error
+{
+ [activityView stopAnimating];
+ self.activityView = nil;
+}
+
+
+#pragma mark -
+#pragma mark UITextFieldDelegate methods
+
+- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
+{
+ DLog(@"begin editing %i", textField.tag);
+
+ // move view to position visibility of form fields
+ CGRect rect = [textField bounds];
+ rect = [textField convertRect:rect toView:self.view];
+ rect.origin.x = 0;
+ rect.origin.y -= 60;
+ rect.size.height = 400;
+
+ // perform the animation
+ [UIView beginAnimations:nil context:NULL];
+// [UIView setAnimationBeginsFromCurrentState:YES];
+ [UIView setAnimationDuration:0.25];
+ [(UIScrollView *)self.view scrollRectToVisible:rect animated:YES];
+ [UIView commitAnimations];
+
+ return YES;
+}
+
+- (BOOL)textFieldShouldReturn:(UITextField *)textField
+{
+ NSInteger cellIndex = textField.tag;
+ NSInteger nextCellIndex = textField.tag + 1;
+ NSInteger lastCellIndex = formCells.count - 1;
+
+ // if we're on the last form field, then close the keyboard
+ if (cellIndex >= lastCellIndex)
+ {
+ GHFormTextFieldCell *cell = formCells.lastObject;
+ [cell.formTextField resignFirstResponder];
+ }
+ // otherwise, select the next form field
+ else if (cellIndex >= 0 && cellIndex < lastCellIndex)
+ {
+ GHFormTextFieldCell *nextCell = [formCells objectAtIndex:nextCellIndex];
+ [nextCell.formTextField becomeFirstResponder];
+ }
+
+ return NO;
+}
+
+
+#pragma mark -
+#pragma mark UIScrollViewDelegate methods
+
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView
+{
+// DLog(@"offset: %f", scrollView.contentOffset.y);
+
+ if (keyboardIsDisplaying)
+ {
+ CGRect toolbarFrame = self.formToolbar.frame;
+ NSInteger viewHeight = self.view.frame.size.height;
+ NSInteger scrollViewOffset = ((UIScrollView *)self.view).contentOffset.y;
+ // TODO: how to get this value here?
+ NSInteger keyboardHeight = 216;
+ NSInteger toolbarHeight = toolbarFrame.size.height;
+
+ // keep the toolbar positioned directly above the keyboard when scrolling
+ toolbarFrame.origin.y = scrollViewOffset + (viewHeight - (keyboardHeight + toolbarHeight));
+ self.formToolbar.frame = toolbarFrame;
+ }
+}
+
+
+#pragma mark -
+#pragma mark UIPickerViewDelegate methods
+
+- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
+{
+ genderTextField.text = [genderValues objectAtIndex:row];
+}
+
+- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
+{
+ return [genderValues objectAtIndex:row];
+}
+
+
+#pragma mark -
+#pragma mark UIPickerViewDataSource methods
+
+- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
+{
+ return 1;
+}
+
+- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
+{
+ return genderValues.count;
+}
+
+
+#pragma mark -
+#pragma mark UITableViewDelegate methods
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ [tableView deselectRowAtIndexPath:indexPath animated:NO];
+}
+
+
+#pragma mark -
+#pragma mark UITableViewDataSource methods
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ UITableViewCell *cell = nil;
+ if (indexPath.row >= 0 && indexPath.row <= formCells.count)
+ {
+ cell = (UITableViewCell *)[formCells objectAtIndex:indexPath.row];
+ }
+ return cell;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ return formCells.count;
+}
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ return 1;
+}
+
+
+#pragma mark -
+#pragma mark UIViewController methods
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ DLog(@"");
+
+ self.navigationItem.title = @"Join Now";
+
+ // add the keyboard toolbar to the view and hide off screen
+ [self.view addSubview:formToolbar];
+ CGRect toolbarFrame = self.formToolbar.frame;
+ toolbarFrame.origin.y = self.containerView.frame.size.height + TOOLBAR_ORIGIN_OFFSET;
+ self.formToolbar.frame = toolbarFrame;
+
+ birthdayPickerView.maximumDate = [NSDate date];
+ genderTextField.inputView = genderPickerView;
+ birthdayTextField.inputView = birthdayPickerView;
+
+ self.formCells = [[NSArray alloc] initWithObjects:firstNameCell, lastNameCell, emailCell, confirmEmailCell, passwordCell, genderCell, birthdayCell, nil];
+ [formCells enumerateObjectsUsingBlock:^(GHFormTextFieldCell *cell, NSUInteger index, BOOL *stop){
+ cell.formTextField.tag = index;
+ }];
+
+ self.genderValues = [[NSArray alloc] initWithObjects:@"", @"Male", @"Female", nil];
+
+ UIScrollView *scrollView = (UIScrollView *)self.view;
+ scrollView.contentSize = containerView.frame.size;
+ [self.view addSubview:containerView];
+}
+
+- (void)viewWillAppear:(BOOL)animated
+{
+ [super viewWillAppear:animated];
+ DLog(@"");
+
+ [self.navigationController setNavigationBarHidden:NO animated:YES];
+ [self addNotificationCenterObservers];
+}
+
+- (void)viewWillDisappear:(BOOL)animated
+{
+ [super viewWillDisappear:animated];
+ DLog(@"");
+
+ [self removeNotificationCenterObservers];
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ DLog(@"");
+
+ self.formCells = nil;
+ self.genderValues = nil;
+ self.activityView = nil;
+ self.containerView = nil;
+ self.containerView = nil;
+ self.signUpForm = nil;
+ self.firstNameCell = nil;
+ self.lastNameCell = nil;
+ self.emailCell = nil;
+ self.confirmEmailCell = nil;
+ self.passwordCell = nil;
+ self.genderCell = nil;
+ self.birthdayCell = nil;
+ self.firstNameCell = nil;
+ self.formToolbar = nil;
+ self.formTextFields = nil;
+ self.firstNameTextField = nil;
+ self.lastNameTextField = nil;
+ self.emailTextField = nil;
+ self.confirmEmailTextField = nil;
+ self.passwordTextField = nil;
+ self.genderTextField = nil;
+ self.birthdayTextField = nil;
+ self.genderPickerView = nil;
+ self.birthdayPickerView = nil;
+}
+
+@end
View
91 Greenhouse/GHOAuth2Controller.m
@@ -1,91 +0,0 @@
-//
-// Copyright 2012 the original author or authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//
-// GHOAuth2Controller.m
-// Greenhouse
-//
-// Created by Roy Clarkson on 8/14/12.
-//
-
-#define KEYCHAIN_SERVICE_NAME @"Greenhouse"
-#define KEYCHAIN_ACCOUNT_NAME @"OAuth2"
-
-#import "GHOAuth2Controller.h"
-#import "OA2SignInRequestParameters.h"
-#import "GHURLPostRequest.h"
-#import "GHKeychainManager.h"
-#import "GHConnectionSettings.h"
-
-@implementation GHOAuth2Controller
-
-
-#pragma mark -
-#pragma mark Static methods
-
-// Use this class method to obtain the shared instance of the class.
-+ (GHOAuth2Controller *)sharedInstance
-{
- static GHOAuth2Controller *_sharedInstance = nil;
- static dispatch_once_t predicate;
- dispatch_once(&predicate, ^{
- _sharedInstance = [[GHOAuth2Controller alloc] init];
- });
- return _sharedInstance;
-}
-
-
-#pragma mark -
-#pragma mark Instance methods
-
-+ (BOOL)isAuthorized
-{
- OA2AccessGrant *accessGrant = [self fetchAccessGrant];
- return (accessGrant != nil);
-}
-
-- (NSURLRequest *)signInRequestWithUsername:(NSString *)username password:(NSString *)password
-{
- OA2SignInRequestParameters *parameters = [[OA2SignInRequestParameters alloc] initWithUsername:username password:password];
- NSURL *url = [GHConnectionSettings urlWithFormat:@"/oauth/token"];
- return [[GHURLPostRequest alloc] initWithURL:url parameters:parameters];
-}
-
-+ (BOOL)storeAccessGrant:(OA2AccessGrant *)accessGrant
-{
- OSStatus status = [[GHKeychainManager sharedInstance] storePassword:[accessGrant dataValue] service:KEYCHAIN_SERVICE_NAME account:KEYCHAIN_ACCOUNT_NAME];
- return (status == errSecSuccess);
-}
-
-+ (OA2AccessGrant *)fetchAccessGrant
-{
- NSData *passwordData;
- OSStatus status = [[GHKeychainManager sharedInstance] fetchPassword:&passwordData service:KEYCHAIN_SERVICE_NAME account:KEYCHAIN_ACCOUNT_NAME];
- if (status == errSecSuccess && passwordData)
- {
- NSError *error;
- OA2AccessGrant *accessGrant = [[OA2AccessGrant alloc] initWithData:passwordData error:&error];
- return accessGrant;
- }
- return nil;
-}
-
-+ (BOOL)deleteAccessGrant
-{
- OSStatus status = [[GHKeychainManager sharedInstance] deletePasswordWithService:KEYCHAIN_SERVICE_NAME account:KEYCHAIN_ACCOUNT_NAME];
- return (status == errSecSuccess);
-}
-
-@end
View
5 Greenhouse/GHProfileMainViewController.m
@@ -25,6 +25,7 @@
#import "GHProfileController.h"
#import "Profile.h"
#import "GHCoreDataManager.h"
+#import "GHAuthController.h"
@interface GHProfileMainViewController()
@@ -47,7 +48,7 @@ @implementation GHProfileMainViewController
- (IBAction)actionSignOut:(id)sender
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
- message:@"Would like to sign out?"
+ message:@"Would you like to sign out?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
@@ -71,7 +72,7 @@ - (IBAction)actionRefresh:(id)sender
- (void)signOut
{
- [GHOAuth2Controller deleteAccessGrant];
+ [GHAuthController deleteAccessGrant];
[[GHCoreDataManager sharedInstance] deletePersistentStore];
[(GreenhouseAppDelegate *)[[UIApplication sharedApplication] delegate] showAuthorizeNavigationViewController];
}
View
4 Greenhouse/GHSignInViewController.h
@@ -21,9 +21,9 @@
//
#import <UIKit/UIKit.h>
+#import "GHAuthControllerDelegate.h"
-
-@interface GHSignInViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>
+@interface GHSignInViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate, GHAuthControllerDelegate>
@property (nonatomic, strong) IBOutlet UIImageView *logoImage;
@property (nonatomic, strong) IBOutlet UITableView *signInForm;
View
120 Greenhouse/GHSignInViewController.m
@@ -25,16 +25,20 @@
#import "GHURLPostRequest.h"
#import "OA2AccessGrant.h"
#import "GHActivityAlertView.h"
+#import "GHAuthController.h"
@interface GHSignInViewController ()
{
BOOL keyboardIsDisplaying;
}
+@property (nonatomic, strong) GHActivityAlertView *activityView;
+
@end
@implementation GHSignInViewController
+@synthesize activityView;
@synthesize logoImage;
@synthesize signInForm;
@synthesize emailCell;
@@ -71,83 +75,9 @@ - (void)signInWithUserName:(NSString *)username andPassword:(NSString *)password
return;
}
- GHActivityAlertView *activityAlertView = [[GHActivityAlertView alloc] initWithActivityMessage:@"Signing in..."];
- [activityAlertView startAnimating];
- NSURLRequest *request = [[GHOAuth2Controller sharedInstance] signInRequestWithUsername:usernameValue password:passwordValue];
- DLog(@"%@", request);
- [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
- [NSURLConnection sendAsynchronousRequest:request
- queue:[[NSOperationQueue alloc] init]
- completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
- {
- [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
- dispatch_sync(dispatch_get_main_queue(), ^{
- [activityAlertView stopAnimating];
- });
-
- NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
- if (statusCode == 200 && data.length > 0 && error == nil)
- {
- DLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
- NSError *errorInternal;
- OA2AccessGrant *accessGrant = [[OA2AccessGrant alloc] initWithData:data error:&errorInternal];
- if (!errorInternal)
- {
- [GHOAuth2Controller storeAccessGrant:accessGrant];
- dispatch_sync(dispatch_get_main_queue(), ^{
- [(GreenhouseAppDelegate *)[[UIApplication sharedApplication] delegate] showTabBarController];
- });
- }
- else
- {
- DLog(@"error parsing access grant: %@", [errorInternal localizedDescription]);
- }
- }
- else if (error)
- {
- DLog(@"%d - %@", [error code], [error localizedDescription]);
- NSString *msg;
- switch ([error code]) {
- case NSURLErrorUserCancelledAuthentication:
- msg = @"Your email or password was entered incorrectly.";
- break;
- case NSURLErrorCannotConnectToHost:
- msg = @"The server is unavailable. Please try again in a few minutes.";
- break;
- default:
- msg = @"A problem occurred with the network connection. Please try again in a few minutes.";
- break;
- }
- dispatch_sync(dispatch_get_main_queue(), ^{
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
- message:msg
- delegate:nil
- cancelButtonTitle:@"OK"
- otherButtonTitles:nil];
- [alert show];
- });
- }
- else if (statusCode != 200)
- {
- DLog(@"HTTP Status Code: %d", statusCode);
- NSString *msg;
- switch (statusCode) {
- default:
- msg = @"You cannot be signed in.";
- break;
- }
- dispatch_sync(dispatch_get_main_queue(), ^{
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
- message:msg
- delegate:nil
- cancelButtonTitle:@"OK"
- otherButtonTitles:nil];
- [alertView show];
- });
- }
- }];
-
- activityAlertView = nil;
+ activityView = [[GHActivityAlertView alloc] initWithActivityMessage:@"Signing in..."];
+ [activityView startAnimating];
+ [[GHAuthController sharedInstance] sendRequestToSignIn:usernameValue password:passwordValue delegate:self];
}
- (void)hideKeyboard
@@ -164,6 +94,15 @@ - (void)hideKeyboard
keyboardIsDisplaying = NO;
}
+- (NSTimeInterval)keyboardAnimationDurationForNotification:(NSNotification*)notification
+{
+ NSDictionary* info = [notification userInfo];
+ NSValue* value = [info objectForKey:UIKeyboardAnimationDurationUserInfoKey];
+ NSTimeInterval duration = 0;
+ [value getValue:&duration];
+ return duration;
+}
+
- (void)keyboardWillShow:(NSNotification *)notification
{
DLog(@"");
@@ -173,11 +112,11 @@ - (void)keyboardWillShow:(NSNotification *)notification
}
CGRect viewFrame = self.view.frame;
- viewFrame.origin.y -= logoImage.frame.size.height;
+ viewFrame.origin.y -= logoImage.frame.size.height + 20;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
- [UIView setAnimationDuration:0.2];
+ [UIView setAnimationDuration:[self keyboardAnimationDurationForNotification:notification]];
[self.view setFrame:viewFrame];
[UIView commitAnimations];
@@ -189,17 +128,35 @@ - (void)keyboardWillHide:(NSNotification *)notification
DLog(@"");
CGRect viewFrame = self.view.frame;
- viewFrame.origin.y += logoImage.frame.size.height;
+ viewFrame.origin.y += logoImage.frame.size.height + 20;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
- [UIView setAnimationDuration:0.2];
+ [UIView setAnimationDuration:[self keyboardAnimationDurationForNotification:notification]];
[self.view setFrame:viewFrame];
[UIView commitAnimations];
keyboardIsDisplaying = NO;
}
+
+#pragma mark -
+#pragma mark GHAuthControllerDelegate methods
+
+- (void)authRequestDidSucceed
+{
+ [activityView stopAnimating];
+ self.activityView = nil;
+ [(GreenhouseAppDelegate *)[[UIApplication sharedApplication] delegate] showTabBarController];
+}
+
+- (void)authRequestDidFailWithError:(NSError *)error
+{
+ [activityView stopAnimating];
+ self.activityView = nil;
+}
+
+
#pragma mark -
#pragma mark UITextFieldDelegate methods
@@ -297,6 +254,7 @@ - (void)viewDidUnload
name:UIKeyboardWillHideNotification
object:nil];
+ self.activityView = nil;
self.logoImage = nil;
self.signInForm = nil;
self.emailCell = nil;
View
42 Greenhouse/GHSignUpForm.h
@@ -0,0 +1,42 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHSignUpForm.h
+// Greenhouse
+//
+// Created by Roy Clarkson on 9/23/12.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface GHSignUpForm : NSObject
+
+@property (nonatomic, copy) NSString *firstName;
+@property (nonatomic, copy) NSString *lastName;
+@property (nonatomic, copy) NSString *email;
+@property (nonatomic, copy) NSString *confirmEmail;
+@property (nonatomic, copy) NSString *password;
+@property (nonatomic, copy) NSString *gender;
+@property (nonatomic, strong) NSDate *birthday;
+@property (nonatomic, assign, readonly) NSInteger birthdayDay;
+@property (nonatomic, assign, readonly) NSInteger birthdayMonth;
+@property (nonatomic, assign, readonly) NSInteger birthdayYear;
+
+- (id)initWithFirstName:(NSString *)firstName lastName:(NSString *)lastName email:(NSString *)email confirmEmail:(NSString *)confirmEmail password:(NSString *)password gender:(NSString *)gender birthdayMonth:(NSInteger)month birthdayDay:(NSInteger)day birthdayYear:(NSInteger)year;
+- (id)initWithFirstName:(NSString *)firstName lastName:(NSString *)lastName email:(NSString *)email confirmEmail:(NSString *)confirmEmail password:(NSString *)password gender:(NSString *)gender birthday:(NSDate *)birthday;
+- (NSDictionary *)dictionaryValue;
+
+@end
View
101 Greenhouse/GHSignUpForm.m
@@ -0,0 +1,101 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHSignUpForm.m
+// Greenhouse
+//
+// Created by Roy Clarkson on 9/23/12.
+//
+
+#import "GHSignUpForm.h"
+
+@implementation GHSignUpForm
+
+@synthesize firstName = _firstName;
+@synthesize lastName = _lastName;
+@synthesize email = _email;
+@synthesize confirmEmail = _confirmEmail;
+@synthesize gender = _gender;
+@synthesize birthday = _birthday;
+@dynamic birthdayDay;
+@dynamic birthdayMonth;
+@dynamic birthdayYear;
+
+- (NSInteger)birthdayDay
+{
+ NSDateComponents *components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit fromDate:self.birthday];
+ return [components day];
+}
+
+- (NSInteger)birthdayMonth
+{
+ NSDateComponents *components = [[NSCalendar currentCalendar] components:NSMonthCalendarUnit fromDate:self.birthday];
+ return [components month];
+}
+
+- (NSInteger)birthdayYear
+{
+ NSDateComponents *components = [[NSCalendar currentCalendar] components:NSYearCalendarUnit fromDate:self.birthday];
+ return [components year];
+}
+
+- (id)initWithFirstName:(NSString *)firstName lastName:(NSString *)lastName email:(NSString *)email confirmEmail:(NSString *)confirmEmail password:(NSString *)password gender:(NSString *)gender birthdayMonth:(NSInteger)month birthdayDay:(NSInteger)day birthdayYear:(NSInteger)year
+{
+ NSDateComponents *components = [[NSDateComponents alloc] init];
+ [components setMonth:month];
+ [components setDay:day];
+ [components setYear:year];
+ NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
+ NSDate *birthday = [calendar dateFromComponents:components];
+ return [self initWithFirstName:firstName lastName:lastName email:email confirmEmail:confirmEmail password:password gender:gender birthday:birthday];
+}
+
+- (id)initWithFirstName:(NSString *)firstName lastName:(NSString *)lastName email:(NSString *)email confirmEmail:(NSString *)confirmEmail password:(NSString *)password gender:(NSString *)gender birthday:(NSDate *)birthday
+{
+ if (self = [super init])
+ {
+ self.firstName = firstName;
+ self.lastName = lastName;
+ self.email = email;
+ self.confirmEmail = confirmEmail;
+ self.password = password;
+ self.gender = gender;
+ self.birthday = birthday;
+ }
+ return self;
+}
+
+- (NSDictionary *)dictionaryValue
+{
+ NSDictionary *birthdate = [[NSDictionary alloc] initWithObjectsAndKeys:
+ [NSNumber numberWithInteger:self.birthdayMonth], @"month",
+ [NSNumber numberWithInteger:self.birthdayDay], @"day",
+ [NSNumber numberWithInteger:self.birthdayYear], @"year",
+ nil];
+
+ NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
+ self.firstName, @"first-name",
+ self.lastName, @"last-name",
+ self.email, @"email",
+ self.confirmEmail, @"confirm-email",
+ self.gender, @"gender",
+ birthdate, @"birthdate",
+ self.password, @"password",
+ nil];
+ return dictionary;
+}
+
+@end
View
20 Greenhouse/Greenhouse-Prefix.pch
@@ -4,30 +4,28 @@
#import <Availability.h>
-#ifndef __IPHONE_4_0
-#warning "This project uses features only available in iPhone SDK 4.0 and later."
+#ifndef __IPHONE_5_0
+#warning "This project uses features only available in iPhone SDK 5.0 and later."
#endif
-
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
- //Debug Logging
+ // Debug Logging
#import "DLog.h"
- // Application Settings
- #import "GHAppSettings.h"
- #import "GHUserSettings.h"
-
// Categories
#import "NSString+Encoding.h"
#import "NSDictionary+Helpers.h"
#import "UIColor+CustomColors.h"
- // Commonly Referenced Classes
- #import "GreenhouseAppDelegate.h"
- #import "GHOauth2Controller.h"
+ // App Delegate
+ #import "GreenhouseAppDelegate.h"
+ // Application Settings
+ #import "GHAppSettings.h"
+ #import "GHUserSettings.h"
+ #import "GHConnectionSettings.h"
#endif
View
5 Greenhouse/GreenhouseAppDelegate.h
@@ -22,17 +22,14 @@
#import <UIKit/UIKit.h>
-@class GHAuthorizeNavigationViewController;
-
@interface GreenhouseAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate, UIAlertViewDelegate>
@property (nonatomic, strong) IBOutlet UIWindow *window;
+@property (nonatomic, strong) IBOutlet UINavigationController *navigationController;
@property (nonatomic, strong) IBOutlet UITabBarController *tabBarController;
-@property (nonatomic, strong) IBOutlet GHAuthorizeNavigationViewController *authorizeNavigationViewController;
- (void)showAuthorizeNavigationViewController;
- (void)showTabBarController;
-- (void)reloadDataForCurrentView;
@end
View
27 Greenhouse/GreenhouseAppDelegate.m
@@ -22,8 +22,7 @@
//#import <CoreLocation/CoreLocation.h>
#import "GreenhouseAppDelegate.h"
-#import "GHAuthorizeNavigationViewController.h"
-#import "GHOAuth2Controller.h"
+#import "GHAuthController.h"
#import "GHCoreDataManager.h"
@interface GreenhouseAppDelegate()
@@ -35,31 +34,23 @@ - (void)verifyLocationServices;
@implementation GreenhouseAppDelegate
@synthesize window;
+@synthesize navigationController;
@synthesize tabBarController;
-@synthesize authorizeNavigationViewController;
- (void)showAuthorizeNavigationViewController
{
[tabBarController.view removeFromSuperview];
- [authorizeNavigationViewController.navigationController popToRootViewControllerAnimated:NO];
- [window addSubview:authorizeNavigationViewController.view];
+ [navigationController popToRootViewControllerAnimated:NO];
+ [window addSubview:navigationController.view];
}
- (void)showTabBarController
{
- [authorizeNavigationViewController.view removeFromSuperview];
+ [navigationController.view removeFromSuperview];
[window addSubview:tabBarController.view];
tabBarController.selectedIndex = 0;
}
-- (void)reloadDataForCurrentView
-{
- if ([tabBarController isViewLoaded] && [tabBarController.selectedViewController respondsToSelector:@selector(reloadData)])
- {
- [tabBarController.selectedViewController performSelector:@selector(reloadData)];
- }
-}
-
- (void)verifyLocationServices
{
// if ([CLLocationManager locationServicesEnabled] == NO)
@@ -80,7 +71,7 @@ - (void)verifyLocationServices
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
// sign out
- [GHOAuth2Controller deleteAccessGrant];
+ [GHAuthController deleteAccessGrant];
[[GHCoreDataManager sharedInstance] deletePersistentStore];
[self showAuthorizeNavigationViewController];
}
@@ -110,7 +101,7 @@ - (void)applicationWillEnterForeground:(UIApplication *)application
if ([GHUserSettings resetAppOnStart])
{
DLog(@"reset app");
- [GHOAuth2Controller deleteAccessGrant];
+ [GHAuthController deleteAccessGrant];
[[GHCoreDataManager sharedInstance] deletePersistentStore];
[GHUserSettings reset];
[GHUserSettings setAppVersion:[GHAppSettings appVersion]];
@@ -133,12 +124,12 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application
DLog(@"");
if ([GHUserSettings resetAppOnStart])
{
- [GHOAuth2Controller deleteAccessGrant];
+ [GHAuthController deleteAccessGrant];
[[GHCoreDataManager sharedInstance] deletePersistentStore];
[GHUserSettings reset];
[self showAuthorizeNavigationViewController];
}
- else if ([GHOAuth2Controller isAuthorized])
+ else if ([GHAuthController isAuthorized])
{
[self showTabBarController];
}
View
317 Greenhouse/en.lproj/GHAuthorizeNavigationViewController.xib
@@ -1,317 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
- <data>
- <int key="IBDocument.SystemTarget">1536</int>
- <string key="IBDocument.SystemVersion">12C54</string>
- <string key="IBDocument.InterfaceBuilderVersion">2840</string>
- <string key="IBDocument.AppKitVersion">1187.34</string>
- <string key="IBDocument.HIToolboxVersion">625.00</string>
- <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
- <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="NS.object.0">1926</string>
- </object>
- <array key="IBDocument.IntegratedClassDependencies">
- <string>IBProxyObject</string>
- <string>IBUINavigationBar</string>
- <string>IBUINavigationController</string>
- <string>IBUINavigationItem</string>
- <string>IBUIView</string>
- <string>IBUIViewController</string>
- </array>
- <array key="IBDocument.PluginDependencies">
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- </array>
- <object class="NSMutableDictionary" key="IBDocument.Metadata">
- <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
- <integer value="1" key="NS.object.0"/>
- </object>
- <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
- <object class="IBProxyObject" id="372490531">
- <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- </object>
- <object class="IBProxyObject" id="975951072">
- <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- </object>
- <object class="IBUIView" id="191373211">
- <reference key="NSNextResponder"/>
- <int key="NSvFlags">274</int>
- <string key="NSFrame">{{0, 20}, {320, 460}}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
- <object class="NSColor" key="IBUIBackgroundColor">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MQA</bytes>
- <object class="NSColorSpace" key="NSCustomColorSpace">
- <int key="NSID">2</int>
- </object>
- </object>
- <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- </object>
- <object class="IBUINavigationController" id="658050802">
- <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
- <object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
- <int key="IBUIInterfaceOrientation">1</int>
- <int key="interfaceOrientation">1</int>
- </object>
- <bool key="IBUIDefinesPresentationContext">YES</bool>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- <bool key="IBUIHorizontal">NO</bool>
- <object class="IBUINavigationBar" key="IBUINavigationBar" id="112303660">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrameSize">{0, 0}</string>
- <string key="NSReuseIdentifierKey">_NS:15</string>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- </object>
- <array class="NSMutableArray" key="IBUIViewControllers">
- <object class="IBUIViewController" id="874774097">
- <object class="IBUINavigationItem" key="IBUINavigationItem" id="513803187">
- <reference key="IBUINavigationBar"/>
- <string key="IBUITitle">Root View Controller</string>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- </object>
- <reference key="IBUIParentViewController" ref="658050802"/>
- <object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
- <int key="IBUIInterfaceOrientation">1</int>
- <int key="interfaceOrientation">1</int>
- </object>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- <bool key="IBUIHorizontal">NO</bool>
- </object>
- </array>
- </object>
- </array>
- <object class="IBObjectContainer" key="IBDocument.Objects">
- <array class="NSMutableArray" key="connectionRecords">
- <object class="IBConnectionRecord">
- <object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">view</string>
- <reference key="source" ref="372490531"/>
- <reference key="destination" ref="191373211"/>
- </object>
- <int key="connectionID">3</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">navigationController</string>
- <reference key="source" ref="372490531"/>
- <reference key="destination" ref="658050802"/>
- </object>
- <int key="connectionID">11</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="658050802"/>
- <reference key="destination" ref="372490531"/>
- </object>
- <int key="connectionID">8</int>
- </object>
- </array>
- <object class="IBMutableOrderedSet" key="objectRecords">
- <array key="orderedObjects">
- <object class="IBObjectRecord">
- <int key="objectID">0</int>
- <array key="object" id="0"/>
- <reference key="children" ref="1000"/>
- <nil key="parent"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">1</int>
- <reference key="object" ref="191373211"/>
- <reference key="parent" ref="0"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-1</int>
- <reference key="object" ref="372490531"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">File's Owner</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-2</int>
- <reference key="object" ref="975951072"/>
- <reference key="parent" ref="0"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">4</int>
- <reference key="object" ref="658050802"/>
- <array class="NSMutableArray" key="children">
- <reference ref="112303660"/>
- <reference ref="874774097"/>
- </array>
- <reference key="parent" ref="0"/>
- </object>
- <object class="IBObjectRecord">