Skip to content

Commit 1e4da02

Browse files
committed
poke at login stuff
1 parent c5d2a97 commit 1e4da02

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

views/settings/index.js

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ import {version} from '../../package.json'
2626

2727
import Communications from 'react-native-communications'
2828
import * as c from '../components/colors'
29-
import {
30-
loadLoginCredentials,
31-
} from '../../lib/login'
29+
import CookieManager from 'react-native-cookies'
3230

3331

3432
export default class SettingsView extends React.Component {
@@ -38,8 +36,7 @@ export default class SettingsView extends React.Component {
3836
}
3937

4038
state = {
41-
username: '',
42-
password: '',
39+
loggedIn: false,
4340
success: false,
4441
loading: false,
4542
attempted: false,
@@ -49,17 +46,10 @@ export default class SettingsView extends React.Component {
4946
this.loadData()
5047
}
5148

52-
_usernameInput: any;
53-
_passwordInput: any;
54-
5549
loadData = async () => {
56-
let [creds, status] = await Promise.all([
57-
loadLoginCredentials(),
50+
let [status] = await Promise.all([
5851
AsyncStorage.getItem('credentials:valid').then(val => JSON.parse(val)),
5952
])
60-
if (creds) {
61-
this.setState({username: creds.username, password: creds.password})
62-
}
6353
if (status) {
6454
this.setState({success: true})
6555
}
@@ -73,19 +63,17 @@ export default class SettingsView extends React.Component {
7363
}
7464

7565
logOut = async () => {
76-
// this.props.navigator.push({
77-
// id: 'SISLoginView',
78-
// index: this.props.route.index + 1,
79-
// })
80-
}
81-
82-
focusUsername = () => {
83-
console.log(this._usernameInput)
84-
this._usernameInput.focus()
85-
}
86-
87-
focusPassword = () => {
88-
this._passwordInput.focus()
66+
this.setState({loading: true})
67+
CookieManager.clearAll((err, res) => {
68+
if (err) {
69+
console.log(err)
70+
}
71+
console.log(res)
72+
this.setState({
73+
success: false,
74+
loading: false,
75+
})
76+
})
8977
}
9078

9179
onPressLegalButton() {
@@ -110,9 +98,6 @@ export default class SettingsView extends React.Component {
11098
}
11199

112100
render() {
113-
let username = this.state.username
114-
let password = this.state.password
115-
116101
let loggedIn = this.state.success
117102
let loading = this.state.loading
118103

views/settings/login.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
WebView,
99
View,
1010
Text,
11+
AsyncStorage,
1112
} from 'react-native'
1213
import startsWith from 'lodash/startsWith'
1314

@@ -63,6 +64,7 @@ export default class SISLoginView extends React.Component {
6364
// If we get redirected back to the HOME_URL we know that we are logged in. If your backend does something different than this
6465
// change this line.
6566
if (startsWith(navState.url, HOME_URL)) {
67+
AsyncStorage.setItem('credentials:valid', JSON.stringify(true))
6668
this.setState({
6769
loggedIn: true,
6870
})

0 commit comments

Comments
 (0)