Skip to content

Commit c3fa532

Browse files
authored
Merge pull request #184 from StoDevX/oauth
Oauth stuff
2 parents 934e720 + 6e31adf commit c3fa532

File tree

10 files changed

+188
-122
lines changed

10 files changed

+188
-122
lines changed

android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ android {
135135
}
136136

137137
dependencies {
138+
compile project(':react-native-cookies')
138139
compile project(':react-native-vector-icons')
139140
compile project(':react-native-keychain')
140141
compile project(':react-native-android-tablayout')

android/app/src/main/java/com/allaboutolaf/MainApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.util.Log;
55

66
import com.facebook.react.ReactApplication;
7+
import com.psykar.cookiemanager.CookieManagerPackage;
78
import com.oblador.vectoricons.VectorIconsPackage;
89
import com.oblador.keychain.KeychainPackage;
910
import com.xebia.reactnative.TabLayoutPackage;
@@ -28,6 +29,7 @@ protected boolean getUseDeveloperSupport() {
2829
protected List<ReactPackage> getPackages() {
2930
return Arrays.<ReactPackage>asList(
3031
new MainReactPackage(),
32+
new CookieManagerPackage(),
3133
new VectorIconsPackage(),
3234
new KeychainPackage(),
3335
new TabLayoutPackage(),

android/settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
rootProject.name = 'All About Olaf'
22

33
include ':app'
4+
include ':react-native-cookies'
5+
project(':react-native-cookies').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cookies/android')
46
include ':react-native-vector-icons'
57
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
68
include ':react-native-keychain'

app.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
TouchableOpacity,
1212
Text,
1313
Platform,
14-
View,
1514
} from 'react-native'
1615

1716
import AboutView from './views/about'
@@ -31,6 +30,7 @@ import TransportationView from './views/transportation'
3130
import OlevilleView from './views/oleville'
3231
import OlevilleNewsStoryView from './views/oleville/latestView'
3332
import SettingsView from './views/settings'
33+
import SISLoginView from './views/settings/login'
3434
import CreditsView from './views/settings/credits'
3535
import PrivacyView from './views/settings/privacy'
3636
import LegalView from './views/settings/legal'
@@ -58,6 +58,7 @@ function renderScene(route, navigator) {
5858
case 'OlevilleView': return <OlevilleView {...props} />
5959
case 'OlevilleNewsStoryView': return <OlevilleNewsStoryView {...props} />
6060
case 'SettingsView': return <SettingsView {...props} />
61+
case 'SISLoginView': return <SISLoginView {...props} />
6162
case 'CreditsView': return <CreditsView {...props} />
6263
case 'PrivacyView': return <PrivacyView {...props} />
6364
case 'LegalView': return <LegalView {...props} />
@@ -209,13 +210,19 @@ function Title(route) {
209210

210211
export default class App extends React.Component {
211212
componentDidMount() {
212-
BackAndroid.addEventListener('hardwareBackPress', () => {
213-
if (this._navigator && this._navigator.getCurrentRoutes().length > 1) {
214-
this._navigator.pop()
215-
return true
216-
}
217-
return false
218-
})
213+
BackAndroid.addEventListener('hardwareBackPress', this.registerAndroidBackButton)
214+
}
215+
216+
componentWillUnmount() {
217+
BackAndroid.removeEventListener('hardwareBackPress', this.registerAndroidBackButton)
218+
}
219+
220+
registerAndroidBackButton = () => {
221+
if (this._navigator && this._navigator.getCurrentRoutes().length > 1) {
222+
this._navigator.pop()
223+
return true
224+
}
225+
return false
219226
}
220227

221228
render() {

ios/AllAboutOlaf.xcodeproj/project.pbxproj

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
};
66
objectVersion = 46;
77
objects = {
8-
98
/* Begin PBXBuildFile section */
109
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
1110
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -36,6 +35,7 @@
3635
F0739B3A70BA995B58032C19 /* libPods-AllAboutOlaf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B997F61616AEE0B6BF79DB54 /* libPods-AllAboutOlaf.a */; };
3736
F5A92AB96CCC44F5A4944718 /* FontAwesome.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 25889372CF4341B19A8A69C5 /* FontAwesome.ttf */; };
3837
FEE667253C1C4F4F891D5B1F /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1A27CF9941A9482697F215C6 /* MaterialIcons.ttf */; };
38+
1F8239F6A983407CB8C0A1F7 /* libRNCookieManagerIOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 124A9486664047EEAF7CBCDF /* libRNCookieManagerIOS.a */; };
3939
/* End PBXBuildFile section */
4040

4141
/* Begin PBXContainerItemProxy section */
@@ -196,6 +196,8 @@
196196
B997F61616AEE0B6BF79DB54 /* libPods-AllAboutOlaf.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AllAboutOlaf.a"; sourceTree = BUILT_PRODUCTS_DIR; };
197197
CF2508C73D024BE2B226091B /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Octicons.ttf"; sourceTree = "<group>"; };
198198
E6FBE71A05CC43E2B4885180 /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf"; sourceTree = "<group>"; };
199+
10892B9A230345CC9EC09E61 /* RNCookieManagerIOS.xcodeproj */ = {isa = PBXFileReference; name = "RNCookieManagerIOS.xcodeproj"; path = "../node_modules/react-native-cookies/RNCookieManagerIOS.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
200+
124A9486664047EEAF7CBCDF /* libRNCookieManagerIOS.a */ = {isa = PBXFileReference; name = "libRNCookieManagerIOS.a"; path = "libRNCookieManagerIOS.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
199201
/* End PBXFileReference section */
200202

201203
/* Begin PBXFrameworksBuildPhase section */
@@ -226,6 +228,7 @@
226228
9B1AE705D4204424A71EE737 /* libRNKeychain.a in Frameworks */,
227229
9304AFEA1BEF4D77A9BE9E47 /* libRNVectorIcons.a in Frameworks */,
228230
F0739B3A70BA995B58032C19 /* libPods-AllAboutOlaf.a in Frameworks */,
231+
1F8239F6A983407CB8C0A1F7 /* libRNCookieManagerIOS.a in Frameworks */,
229232
);
230233
runOnlyForDeploymentPostprocessing = 0;
231234
};
@@ -400,6 +403,7 @@
400403
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
401404
A91038679F834707B769D282 /* RNKeychain.xcodeproj */,
402405
71D5CCADA66D45008D9A38F2 /* RNVectorIcons.xcodeproj */,
406+
10892B9A230345CC9EC09E61 /* RNCookieManagerIOS.xcodeproj */,
403407
);
404408
name = Libraries;
405409
sourceTree = "<group>";
@@ -893,7 +897,10 @@
893897
INFOPLIST_FILE = AllAboutOlafTests/Info.plist;
894898
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
895899
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
896-
LIBRARY_SEARCH_PATHS = "$(inherited)";
900+
LIBRARY_SEARCH_PATHS = (
901+
"$(inherited)",
902+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
903+
);
897904
ONLY_ACTIVE_ARCH = YES;
898905
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
899906
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -909,7 +916,10 @@
909916
INFOPLIST_FILE = AllAboutOlafTests/Info.plist;
910917
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
911918
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
912-
LIBRARY_SEARCH_PATHS = "$(inherited)";
919+
LIBRARY_SEARCH_PATHS = (
920+
"$(inherited)",
921+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
922+
);
913923
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
914924
PRODUCT_NAME = "$(TARGET_NAME)";
915925
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/All About Olaf.app/All About Olaf";
@@ -931,6 +941,7 @@
931941
"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager",
932942
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
933943
"$(SRCROOT)/../node_modules/react-native-onesignal/**",
944+
"$(SRCROOT)/../node_modules/react-native-cookies/RNCookieManagerIOS",
934945
);
935946
INFOPLIST_FILE = AllAboutOlaf/Info.plist;
936947
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -957,6 +968,7 @@
957968
"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager",
958969
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
959970
"$(SRCROOT)/../node_modules/react-native-onesignal/**",
971+
"$(SRCROOT)/../node_modules/react-native-cookies/RNCookieManagerIOS",
960972
);
961973
INFOPLIST_FILE = AllAboutOlaf/Info.plist;
962974
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -1011,6 +1023,7 @@
10111023
"$(SRCROOT)/../node_modules/react-native/React/**",
10121024
"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager",
10131025
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
1026+
"$(SRCROOT)/../node_modules/react-native-cookies/RNCookieManagerIOS",
10141027
);
10151028
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
10161029
MTL_ENABLE_DEBUG_INFO = YES;
@@ -1053,6 +1066,7 @@
10531066
"$(SRCROOT)/../node_modules/react-native/React/**",
10541067
"$(SRCROOT)/../node_modules/react-native-keychain/RNKeychainManager",
10551068
"$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
1069+
"$(SRCROOT)/../node_modules/react-native-cookies/RNCookieManagerIOS",
10561070
);
10571071
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
10581072
MTL_ENABLE_DEBUG_INFO = NO;

lib/courses.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// @flow
22
import {
3-
api,
4-
loadLoginCredentials,
5-
sisLogin,
3+
api,
4+
isLoggedIn,
65
} from '../lib/login'
76
import { AsyncStorage, NetInfo } from 'react-native'
87

@@ -118,8 +117,9 @@ async function getTermListFromStorage(): Promise<number[]> {
118117
}
119118

120119
async function getTermListFromServer(): Promise<number[]> {
121-
let {username, password} = await loadLoginCredentials()
122-
let {result} = await sisLogin(username, password)
120+
// let {username, password} = await loadLoginCredentials()
121+
// let {result} = await sisLogin(username, password)
122+
let result = await isLoggedIn()
123123
if (!result) {
124124
return []
125125
}
@@ -136,6 +136,7 @@ async function getTermListFromServer(): Promise<number[]> {
136136
} else if (stunum.choices) {
137137
throw new Error('multiple student numbers!')
138138
}
139+
139140
let terms = cssSelect('[name=searchyearterm]', dom)[0]
140141
.children
141142
.filter(node => node.type === 'tag' && node.name === 'option')

lib/financials.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @flow
22
import {
3-
api,
4-
loadLoginCredentials,
5-
sisLogin,
3+
api,
4+
loadLoginCredentials,
5+
isLoggedIn,
66
} from '../lib/login'
77
import { AsyncStorage, NetInfo } from 'react-native'
88

@@ -52,8 +52,9 @@ async function getSisFinancialsPage() {
5252
}
5353

5454
async function getFinancialDataFromServer(): Promise<FinancialDataShapeType> {
55-
let {username, password} = await loadLoginCredentials()
56-
let {result} = await sisLogin(username, password)
55+
// let {username, password} = await loadLoginCredentials()
56+
// let {result} = await sisLogin(username, password)
57+
let result = await isLoggedIn()
5758
if (!result) {
5859
return {flex: null, ole: null, print: null}
5960
}
@@ -85,6 +86,7 @@ async function getFinancialDataFromServer(): Promise<FinancialDataShapeType> {
8586
}
8687

8788

89+
// TODO: come up with a better story around auth for olecard
8890
export default async function getWeeklyMealsRemaining() {
8991
let {username, password} = await loadLoginCredentials()
9092
let form = buildFormData({

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"react-native-calendar": "0.6.4",
4444
"react-native-collapsible": "0.7.0",
4545
"react-native-communications": "2.1.0",
46+
"react-native-cookies": "1.0.2",
4647
"react-native-keychain": "0.3.2",
4748
"react-native-onesignal": "1.2.0",
4849
"react-native-refreshable-listview": "1.3.0",

0 commit comments

Comments
 (0)