Skip to content

Commit ae840a9

Browse files
Merge pull request #515 from mean-expert-official/development
Development
2 parents 640b438 + 997856c commit ae840a9

File tree

99 files changed

+69629
-60
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+69629
-60
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*.pid
1111
*.swp
1212
*.swo
13+
*package-lock.json
1314
node_modules
1415
bower_component
1516
checkstyle.xml

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
This file is created to keep history of the LoopBack SDK Builder, it does not consider or keeps any history of its parent module `loopback-sdk-angular`
44

5+
## Release 2.1.0-rc.14
6+
7+
- Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/48?closed=1
8+
9+
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/515
10+
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/514
11+
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/511
12+
- WIP: https://github.com/mean-expert-official/loopback-sdk-builder/issues/495
13+
514
## Release 2.1.0-rc.13.5
615

716
- Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/47?closed=1

bin/lb-sdk

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,23 @@ var argv = optimist
2323
'\nGenerate Client SDK for your LoopBack Application.' +
2424
'\nUsage:' +
2525
'\n ./node_modules/.bin/lb-sdk server/server app/shared/sdk -d [ng2web | ng2native | ng2universal] -i [enabled | disabled] -v [enabled | strict | disabled]')
26-
.describe('l', 'Client\'s library (angular2, react <todo>, ...)')
27-
.describe('d', 'Platform specific drivers (ng2web, ng2native, ng2universal)')
26+
.describe('l', 'Client\'s library (angular, react, vuejs <todo> ...)')
27+
.describe('d', 'Platform specific drivers (ng2web, ng2native, ng2universal, react-web)')
2828
.describe('i', 'Enable PubSub, IO and FireLoop functionality')
2929
.describe('w', 'Automatically wipe SDK Directory')
3030
.describe('v', 'Add default values in models')
3131
.describe('f', 'Generate only FireLoop SDK + Auth Services')
3232
.describe('q', 'quiet mode - no console output (forces -w)')
33+
.describe('t', 'Enable Typescript default true ( React Only )')
3334
.default('l', 'angular2')
3435
.default('d', 'ng2web')
3536
.default('i', 'enabled')
3637
.default('w', 'disabled')
3738
.default('v', 'disabled')
3839
.default('f', 'disabled')
3940
.default('q', false)
40-
.alias({ u: 'url', m: 'module-name', l: 'library', i: 'io', d: 'driver', w: 'wipe', v: 'default-values', f: 'fireloop-only', q: 'quiet' })
41+
.default('t', true)
42+
.alias({ u: 'url', m: 'module-name', l: 'library', i: 'io', d: 'driver', w: 'wipe', v: 'default-values', f: 'fireloop-only', q: 'quiet', t: 'typescript' })
4143
.demand(1)
4244
.argv;
4345
/**
@@ -87,7 +89,6 @@ var appFile = path.resolve(argv._[0]);
8789
* Load and Boot LoopBack Application
8890
*/
8991
var app = require(appFile);
90-
9192
// Default Values
9293
var context = {
9394
app: app,
@@ -100,7 +101,8 @@ var context = {
100101
wipe: argv['w'] || 'disabled',
101102
defaultValue: argv['v'] || 'disabled',
102103
fireloopOnly: argv['f'] || 'disabled',
103-
quiet: argv['q'] || false
104+
quiet: argv['q'] || false,
105+
isTyped: argv['t'] == 'false' ? false : true
104106
};
105107

106108
if (context.quiet) {

lib/angular2/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ module.exports = function generate(ctx) {
387387
// the password property anymore but is required for TypeScript purposes
388388
if (model.isUser && !model.properties.password) {
389389
model.properties.password = {
390-
type: model.properties.username.type
390+
type: String
391391
}
392392
}
393393
// Add Model Properties

lib/angular2/shared/config.ejs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class LoopBackConfig {
2626
private static debug: boolean = true;
2727
private static filterOn: string = 'headers';
2828
private static secure: boolean = false;
29+
private static withCredentials: boolean = false;
2930

3031
public static setApiVersion(version: string = 'api'): void {
3132
LoopBackConfig.version = version;
@@ -82,4 +83,12 @@ export class LoopBackConfig {
8283
public static isSecureWebSocketsSet(): boolean {
8384
return LoopBackConfig.secure;
8485
}
86+
87+
public static setRequestOptionsCredentials(withCredentials: boolean = false): void {
88+
LoopBackConfig.withCredentials = withCredentials;
89+
}
90+
91+
public static getRequestOptionsCredentials(): boolean {
92+
return LoopBackConfig.withCredentials;
93+
}
8594
}

lib/angular2/shared/services/core/auth.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ export class LoopBackAuth {
114114
**/
115115
public save(): boolean {
116116
if (this.token.rememberMe) {
117-
this.persist('id', this.token.id);
118-
this.persist('user', this.token.user);
119-
this.persist('userId', this.token.userId);
120-
this.persist('created', this.token.created);
121-
this.persist('ttl', this.token.ttl);
122-
this.persist('rememberMe', this.token.rememberMe);
117+
let today = new Date();
118+
let expires = new Date(today.getTime() + (this.token.ttl * 1000));
119+
this.persist('id', this.token.id, expires);
120+
this.persist('user', this.token.user, expires);
121+
this.persist('userId', this.token.userId, expires);
122+
this.persist('created', this.token.created, expires);
123+
this.persist('ttl', this.token.ttl, expires);
124+
this.persist('rememberMe', this.token.rememberMe, expires);
123125
return true;
124126
} else {
125127
return false;
@@ -151,11 +153,12 @@ export class LoopBackAuth {
151153
* @description
152154
* This method saves values to storage
153155
**/
154-
protected persist(prop: string, value: any): void {
156+
protected persist(prop: string, value: any, expires?: Date): void {
155157
try {
156158
this.storage.set(
157159
`${this.prefix}${prop}`,
158-
(typeof value === 'object') ? JSON.stringify(value) : value
160+
(typeof value === 'object') ? JSON.stringify(value) : value,
161+
expires
159162
);
160163
}
161164
catch (err) {

lib/angular2/shared/services/core/base.ejs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export abstract class BaseLoopBackApi {
8484
if (LoopBackConfig.isHeadersFilteringSet()) {
8585
headers.append('filter', JSON.stringify(urlParams.filter));
8686
} else {
87-
filter = `?filter=${ encodeURI(JSON.stringify(urlParams.filter))}`;
87+
filter = `?filter=${ encodeURIComponent(JSON.stringify(urlParams.filter))}`;
8888
}
8989
delete urlParams.filter;
9090
}
@@ -104,12 +104,12 @@ export abstract class BaseLoopBackApi {
104104
this.searchParams.setJSON(urlParams);
105105
let request: Request = new Request(
106106
new RequestOptions({
107-
headers : headers,
108-
method : method,
109-
url : `${url}${filter}`,
110-
search : Object.keys(urlParams).length > 0
111-
? this.searchParams.getURLSearchParams() : null,
112-
body : body ? JSON.stringify(body) : undefined
107+
headers : headers,
108+
method : method,
109+
url : `${url}${filter}`,
110+
search : Object.keys(urlParams).length > 0 ? this.searchParams.getURLSearchParams() : null,
111+
body : body ? JSON.stringify(body) : undefined,
112+
withCredentials: LoopBackConfig.getRequestOptionsCredentials()
113113
})
114114
);
115115
return this.http.request(request)

lib/angular2/shared/storage/storage.browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class StorageBrowser {
2929
* @description
3030
* The setter will return any type of data persisted in localStorage.
3131
**/
32-
set(key: string, value: any): void {
32+
set(key: string, value: any, expires?: Date): void {
3333
localStorage.setItem(
3434
key,
3535
typeof value === 'object' ? JSON.stringify(value) : value

lib/angular2/shared/storage/storage.native.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class StorageNative {
3030
* @description
3131
* The setter will return any type of data persisted in localStorage.
3232
**/
33-
set(key: string, value: any): void {
33+
set(key: string, value: any, expires?: Date): void {
3434
AppSettings.setString(
3535
key,
3636
String(typeof value === 'object' ? JSON.stringify(value) : value)

lib/angular2/shared/storage/storage.swaps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class BaseStorage {
2323
* @description
2424
* The setter will return any type of data persisted in localStorage.
2525
**/
26-
set(key: string, value: any): void {}
26+
set(key: string, value: any, expires?: Date): void {}
2727
/**
2828
* @method remove
2929
* @param {string} key Storage key name

0 commit comments

Comments
 (0)