Skip to content

Instantly share code, notes, and snippets.

View spencercarli's full-sized avatar

Spencer Carli spencercarli

View GitHub Profile
@spencercarli
spencercarli / loggedIn.js
Created February 14, 2016 20:42
Meteor Authentication from React Native - The UI
// RNApp/app/loggedIn.js
import React, {
View,
Text
} from 'react-native';
import Button from './button';
import ddpClient from './ddp';
@spencercarli
spencercarli / index.js
Created February 14, 2016 20:43
Meteor Authentication from React Native - The UI - index.js
// RNApp/app/index.js
import React, {
View,
StyleSheet
} from 'react-native';
import ddpClient from './ddp';
import LoggedIn from './loggedIn';
@spencercarli
spencercarli / loggedOut.js
Created February 14, 2016 20:44
Meteor Authentication from React Native - UI: Sign In
// RNApp/app/loggedOut.js
import React, {
View,
Text,
TextInput,
StyleSheet
} from 'react-native';
import Button from './button';
@spencercarli
spencercarli / index.js
Created February 14, 2016 20:45
Meteor Authentication from React Native - UI: Sign In - index.js
// RNApp/app/index.js
/*
* Removed from snippet for brevity
*/
import LoggedOut from './loggedOut';
export default React.createClass({
getInitialState() {
return {
@spencercarli
spencercarli / loggedIn.js
Last active February 14, 2016 20:51
Meteor Authentication from React Native - UI: Sign In - loggedIn.js
// RNApp/app/loggedIn.js
/*
* Removed from snippet for brevity
*/
export default React.createClass({
/*
* Removed from snippet for brevity
*/
@spencercarli
spencercarli / loggedOut.js
Created February 14, 2016 20:47
Meteor Authentication from React Native - UI: Sign In - loggedOut.js
// RNApp/app/loggedOut.js
import React, {
View,
Text,
TextInput,
StyleSheet,
AsyncStorage // Import AsyncStorage
} from 'react-native';
@spencercarli
spencercarli / posts.js
Created February 14, 2016 20:48
Meteor Authentication from React Native - posts.js
// meteor-app/both/posts.js
'addPost': function() {
Posts.insert({
title: 'Post ' + Random.id(),
userId: this.userId
});
},
@spencercarli
spencercarli / home.html
Created February 16, 2016 01:03
Password Hashing for Meteor React Native - Adding Accounts to the Meteor App
<!-- In /meteor-app/client/home.html -->
<template name="home">
{{> loginButtons}}
<h1>Post Count: {{count}}</h1>
<button id="increment">Increment</button>
<button id="decrement">Decrement</button>
</template>
@spencercarli
spencercarli / ddp.js
Created February 16, 2016 01:05
Password Hashing for Meteor React Native - Hashing - Part 1
// In RNApp/app/ddp.js
import DDPClient from 'ddp-client';
import hash from 'hash.js';
import { AsyncStorage } from 'react-native';
let ddpClient = new DDPClient({
host: 'localhost',
port: '3000',
// url: <your websocket url>
});
@spencercarli
spencercarli / ddp.js
Created February 16, 2016 01:06
Password Hashing for Meteor React Native - Hashing - Part 2
// In RNApp/app/ddp.js
/*
* Removed from snippet for brevity
*/
ddpClient.sha256 = (password) => {
return {
digest: hash.sha256().update(password).digest('hex'),
algorithm: "sha-256"