Skip to content

Commit

Permalink
Updated Readme, added information display to example app
Browse files Browse the repository at this point in the history
  • Loading branch information
mebinum committed Apr 22, 2019
1 parent 4911f9f commit 61ab1cf
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ___
* AzureInstance
* AzureLoginView
* Auth
* [Example](#example)

## Installation
Install package from `npm`
Expand Down Expand Up @@ -107,3 +108,7 @@ export default class azureAuth extends React.Component {

AppRegistry.registerComponent('azureAuth', () => azureAuth);
```

## Example

To see see an example app using the library have a look at the [Example Project](example/README.md)
46 changes: 35 additions & 11 deletions example/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { StyleSheet } from 'react-native';
import { StyleSheet, Text, View } from 'react-native';
import {AzureInstance, AzureLoginView} from 'react-native-azure-ad-2';

const credentials = {
Expand All @@ -11,27 +11,46 @@ const credentials = {
export default class App extends React.Component {
constructor(props){
super(props);

this.state = {
azureLoginObject: {},
loginSuccess: false
};
this.azureInstance = new AzureInstance(credentials);
this._onLoginSuccess = this._onLoginSuccess.bind(this);
}

_onLoginSuccess(){
this.azureInstance.getUserInfo().then(result => {
console.log(result);
this.setState({
loginSuccess: true,
azureLoginObject: result
});
console.log(result);
}).catch(err => {
console.log(err);
})
}
}


render() {
return (
<AzureLoginView
azureInstance={this.azureInstance}
loadingMessage="Requesting access token"
onSuccess={this._onLoginSuccess}
/>
);

if (!this.state.loginSuccess) {

return (<AzureLoginView
azureInstance={this.azureInstance}
loadingMessage="Requesting access token"
onSuccess={this._onLoginSuccess}
/>)
}

const {userPrincipalName, givenName} = this.state.azureLoginObject;

return (
<View style={styles.container}>
<Text style={styles.text}>Welcome {givenName}</Text>
<Text style={styles.text}>You logged into Azure with {userPrincipalName}</Text>
</View>
);
}
}

Expand All @@ -42,4 +61,9 @@ const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
text: {
textAlign: 'center',
color: '#333333',
marginBottom: 5
}
});
2 changes: 1 addition & 1 deletion example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 61ab1cf

Please sign in to comment.