Skip to content

Commit

Permalink
merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
powerful23 committed Jan 18, 2018
2 parents 660e0f8 + aaf9e0f commit c3adb0d
Show file tree
Hide file tree
Showing 41 changed files with 3,557 additions and 1,369 deletions.
52 changes: 34 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
# Changelog for AWS Amplify
<!--LATEST=0.1.30-->
<!--LATEST=0.1.35-->
<!--ENTRYINSERT-->

## 12/22/2017
## 01/16/2018
* aws-amplify - v0.1.35
* Improvements to Typescript developer experience. #155
* fix RN props #158
* delete ama #142
* aws-amplify-react-native - v0.1.23
* fix RN props #158

## 01/12/2018
* aws-amplify-react-native - v0.1.22
* bug fix: fix aws-sdk package
## 01/11/2018
* aws-amplify - v0.1.34
* bug fix: fix aws-sdk package
* bug fix: update main script

* aws-amplify - v0.1.30
## 01/09/2018

* aws-amplify - v0.1.32
* aws-amplify-react - v0.1.30
* aws-amplify-react-native - v0.1.20
* aws-ampliify-react-native - v0.1.21

* feature: Federated Authentication with Google and Facebook in React
* bugFix: Federated auth token fixes
* feature: Automatic S3 Analytics tracking with React components
* feature: Increase unit test coverage
* feature: Jest snapshot update
* feature: Update default auth theme
* feature: Export Signer interface for 3rd party HttpModules
* bugFix: aws-amplify-react-native: Update pinpoint region in React Native
* feature: Better support for guest (Unauthenticated) credentials
* bugFix: documentation: Fix broken link (to authentication)
* Enhancement: remove aws-sdk-mobile-analytics dependency from package.json

## 01/08/2018

Expand All @@ -33,10 +40,19 @@
* Bug fix: Doc syntax error fix
* Bug fix: Add charset on default header for API

## 01/09/2018
## 12/22/2017

* aws-amplify - v0.1.32
* aws-amplify - v0.1.30
* aws-amplify-react - v0.1.30
* aws-ampliify-react-native - v0.1.21
* aws-amplify-react-native - v0.1.20

* Enhancement: remove aws-sdk-mobile-analytics dependency from package.json
* feature: Federated Authentication with Google and Facebook in React
* bugFix: Federated auth token fixes
* feature: Automatic S3 Analytics tracking with React components
* feature: Increase unit test coverage
* feature: Jest snapshot update
* feature: Update default auth theme
* feature: Export Signer interface for 3rd party HttpModules
* bugFix: aws-amplify-react-native: Update pinpoint region in React Native
* feature: Better support for guest (Unauthenticated) credentials
* bugFix: documentation: Fix broken link (to authentication)
9 changes: 8 additions & 1 deletion media/authentication_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ Auth.confirmSignIn(user, code)
```js
import { Auth } from 'aws-amplify';

Auth.signUp(username, password, email, phone)
Auth.signUp({
username,
password,
email, // optional
phone, // optional
// other custom attributes if has been set in Cognito
// myAttr: ...
})
.then(data => console.log(data))
.catch(err => console.log(err));

Expand Down
42 changes: 29 additions & 13 deletions packages/aws-amplify-react-native/dist/Auth/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,46 @@ class AuthClass {

/**
* Sign up with username, password and other attrbutes like phone, email
* @param {String} username - The username to be signed up
* @param {String} password - The password of the user
* @param {String} email - The email of the user
* @param {String} phone_number - the phone number of the user
* @return {Promise} - A promise resolves callback data if success
* @param {String | object} attrs - The user attirbutes used for signin
* @param {String[]} restOfAttrs - for the backward compatability
* @return - A promise resolves callback data if success
*/
signUp(username, password, email, phone_number) {
signUp(attrs, ...restOfAttrs) {
if (!this.userPool) {
return Promise.reject('No userPool');
}

let username = null;
let password = null;
const attributes = [];
if (attrs && typeof attrs === 'string') {
username = attrs;
password = restOfAttrs ? restOfAttrs[0] : null;
const email = restOfAttrs ? restOfAttrs[1] : null;
const phone_number = restOfAttrs ? restOfAttrs[2] : null;
if (email) attributes.push({ Name: 'email', Value: email });
if (phone_number) attributes.push({ Name: 'phone_number', Value: phone_number });
} else if (attrs && typeof attrs === 'object') {
username = attrs['username'];
password = attrs['password'];
Object.keys(attrs).map(key => {
if (key === 'username' || key === 'password') return;
const ele = { Name: key, Value: attrs[key] };
attributes.push(ele);
});
} else {
return Promise.reject('The first parameter should either be non-null string or object');
}

if (!username) {
return Promise.reject('Username cannot be empty');
}
if (!password) {
return Promise.reject('Password cannot be empty');
}

const attributes = [];
if (email) {
attributes.push({ Name: 'email', Value: email });
}
if (phone_number) {
attributes.push({ Name: 'phone_number', Value: phone_number });
}
logger.debug('signUp attrs:');
logger.debug(attributes);

return new Promise((resolve, reject) => {
this.userPool.signUp(username, password, attributes, null, function (err, data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import VerifyContact from './VerifyContact';
import SignUp from './SignUp';
import ConfirmSignUp from './ConfirmSignUp';
import ForgotPassword from './ForgotPassword';
import RequireNewPassword from './RequireNewPassword';
import Greetings from './Greetings';

const logger = new Logger('Authenticator');
Expand Down Expand Up @@ -57,7 +58,7 @@ export default class Authenticator extends React.Component {
super(props);
this.state = {
authState: props.authState || 'signIn',
authDate: props.authData
authData: props.authData
};

this.handleStateChange = this.handleStateChange.bind(this);
Expand Down Expand Up @@ -106,7 +107,7 @@ export default class Authenticator extends React.Component {

const { hideDefault } = this.props;
const props_children = this.props.children || [];
const default_children = [React.createElement(SignIn, null), React.createElement(ConfirmSignIn, null), React.createElement(VerifyContact, null), React.createElement(SignUp, null), React.createElement(ConfirmSignUp, null), React.createElement(ForgotPassword, null), React.createElement(Greetings, null)];
const default_children = [React.createElement(SignIn, null), React.createElement(ConfirmSignIn, null), React.createElement(VerifyContact, null), React.createElement(SignUp, null), React.createElement(ConfirmSignUp, null), React.createElement(ForgotPassword, null), React.createElement(RequireNewPassword, null), React.createElement(Greetings, null)];
const children = (hideDefault ? [] : default_children).concat(props_children).map((child, index) => {
return React.cloneElement(child, {
key: 'auth_piece_' + index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class RequireNewPassword extends AuthPiece {
React.createElement(Button, {
title: I18n.get('Change Password'),
onPress: this.change,
disabled: !this.state.code
disabled: !this.state.password
})
),
React.createElement(Footer, { theme: theme, onStateChange: this.changeState }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export default class VerifyContact extends AuthPiece {
selectedValue: this.state.pickAttr,
onValueChange: (value, index) => this.setState({ pickAttr: value })
},
email ? React.createElement(Picker.Item, { label: 'Email', value: 'email' }) : null,
phone_number ? React.createElement(Picker.Item, { label: 'Phone Number', value: 'phone_number' }) : null
email ? React.createElement(Picker.Item, { label: I18n.get('Email'), value: 'email' }) : null,
phone_number ? React.createElement(Picker.Item, { label: I18n.get('Phone Number'), value: 'phone_number' }) : null
),
React.createElement(Button, {
title: I18n.get('Verify'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import ConfirmSignIn from './ConfirmSignIn';
import SignUp from './SignUp';
import ConfirmSignUp from './ConfirmSignUp';
import ForgotPassword from './ForgotPassword';
import RequireNewPassword from './RequireNewPassword';
import VerifyContact from './VerifyContact';
import Greetings from './Greetings';

const logger = new Logger('auth components');

export { Authenticator, AuthPiece, SignIn, ConfirmSignIn, SignUp, ConfirmSignUp, ForgotPassword, VerifyContact, Greetings };
export { Authenticator, AuthPiece, SignIn, ConfirmSignIn, SignUp, ConfirmSignUp, ForgotPassword, RequireNewPassword, VerifyContact, Greetings };

export function withAuthenticator(Comp, includeGreetings = false) {
class Wrapper extends React.Component {
Expand Down
12 changes: 6 additions & 6 deletions packages/aws-amplify-react-native/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/aws-amplify-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aws-amplify-react-native",
"version": "0.1.22",
"version": "0.1.23",
"description": "AWS Amplify is a JavaScript library for Frontend and mobile developers building cloud-enabled applications.",
"main": "dist/index.js",
"scripts": {
Expand Down
46 changes: 35 additions & 11 deletions packages/aws-amplify-react-native/src/Auth/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,48 @@ class AuthClass {

/**
* Sign up with username, password and other attrbutes like phone, email
* @param {String} username - The username to be signed up
* @param {String} password - The password of the user
* @param {String} email - The email of the user
* @param {String} phone_number - the phone number of the user
* @return {Promise} - A promise resolves callback data if success
* @param {String | object} attrs - The user attirbutes used for signin
* @param {String[]} restOfAttrs - for the backward compatability
* @return - A promise resolves callback data if success
*/
signUp(username, password, email, phone_number) {
signUp(attrs, ...restOfAttrs) {
if (!this.userPool) { return Promise.reject('No userPool'); }
if (!username) { return Promise.reject('Username cannot be empty'); }
if (!password) { return Promise.reject('Password cannot be empty'); }

let username = null;
let password = null;
const attributes = [];
if (email) { attributes.push({Name: 'email', Value: email}); }
if (phone_number) { attributes.push({Name: 'phone_number', Value: phone_number}); }
if (attrs && typeof attrs === 'string') {
username = attrs;
password = restOfAttrs? restOfAttrs[0] : null;
const email = restOfAttrs? restOfAttrs[1] : null;
const phone_number = restOfAttrs? restOfAttrs[2] : null;
if (email) attributes.push({Name: 'email', Value: email});
if (phone_number) attributes.push({Name: 'phone_number', Value: phone_number});
} else if (attrs && typeof attrs === 'object') {
username = attrs['username'];
password = attrs['password'];
Object.keys(attrs).map(key => {
if (key === 'username' || key === 'password') return;
const ele = { Name: key, Value: attrs[key] };
attributes.push(ele);
});
} else {
return Promise.reject('The first parameter should either be non-null string or object');
}

if (!username) { return Promise.reject('Username cannot be empty'); }
if (!password) { return Promise.reject('Password cannot be empty'); }

logger.debug('signUp attrs:');
logger.debug(attributes);

return new Promise((resolve, reject) => {
this.userPool.signUp(username, password, attributes, null, function(err, data) {
if (err) { reject(err); } else { resolve(data); }
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
}
Expand Down
6 changes: 3 additions & 3 deletions packages/aws-amplify-react/__tests__/Storage/S3Album-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe('S3Album test', () => {

expect.assertions(2);
expect(spyon).toBeCalledWith({"file": "file", "name": "name", "size": "size", "type": "type"});
expect(spyon2).toBeCalledWith('path', 'file', {contentType: 'type'});
expect(spyon2).toBeCalledWith('path', 'file', {"contentType": "type", "level": "public", "track": undefined});

spyon.mockClear();
spyon2.mockClear();
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('S3Album test', () => {

expect.assertions(3);
expect(spyon).toBeCalledWith({"file": "file", "name": "name", "size": "size", "type": "type"});
expect(spyon2).toBeCalledWith('path', 'file', {contentType: 'type'});
expect(spyon2).toBeCalledWith('path', 'file', {"contentType": "type", "level": "public", "track": undefined});
expect(spyon3).toBeCalledWith([{key: 'path2'}, 'data']);

spyon.mockClear();
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('S3Album test', () => {

expect.assertions(2);
expect(spyon).toBeCalledWith({"file": "file", "name": "name", "size": "size", "type": "type"});
expect(spyon2).toBeCalledWith('path', 'file', {contentType: 'type'});
expect(spyon2).toBeCalledWith('path', 'file', {"contentType": "type", "level": "public", "track": undefined});

spyon.mockClear();
spyon2.mockClear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('S3Image', () => {
await s3Image.handlePick(data);

expect.assertions(2);
expect(spyon).toBeCalledWith('imgKey', 'file', {contentType: 'type'});
expect(spyon).toBeCalledWith('imgKey', 'file', {"contentType": "type", "level": "level", "track": undefined});
expect(spyon2).toBeCalled();

spyon.mockClear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('S3Text test', () => {
await s3Text.handlePick(data);

expect.assertions(2);
expect(spyon).toBeCalledWith('textKey', 'file', { contentType: 'type' });
expect(spyon).toBeCalledWith('textKey', 'file', {"contentType": "type", "level": "level", "track": undefined});
expect(spyon2).toBeCalled();

spyon.mockClear();
Expand Down
9 changes: 7 additions & 2 deletions packages/aws-amplify-react/dist/Storage/S3Album.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ var S3Album = function (_Component) {
onPick = _props.onPick,
onLoad = _props.onLoad,
onError = _props.onError,
track = _props.track;
track = _props.track,
level = _props.level;


if (onPick) {
Expand All @@ -129,7 +130,11 @@ var S3Album = function (_Component) {
type = data.type;

var key = path + this.getKey(data);
_awsAmplify.Storage.put(key, file, { contentType: type, track: track }).then(function (data) {
_awsAmplify.Storage.put(key, file, {
level: level ? level : 'public',
contentType: type,
track: track
}).then(function (data) {
logger.debug('handle pick data', data);
var items = _this2.state.items;

Expand Down
6 changes: 5 additions & 1 deletion packages/aws-amplify-react/dist/Storage/S3Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ var S3Image = function (_Component) {
type = data.type;

var key = imgKey || path + (0, _Common.calcKey)(data, fileToKey);
_awsAmplify.Storage.put(key, file, { contentType: type, track: track }).then(function (data) {
_awsAmplify.Storage.put(key, file, {
level: level ? level : 'public',
contentType: type,
track: track
}).then(function (data) {
logger.debug('handle pick data', data);
that.getImageSource(key, level, track);
})['catch'](function (err) {
Expand Down
Loading

0 comments on commit c3adb0d

Please sign in to comment.