mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
@@ -1,7 +1,24 @@
|
|||||||
# Alfresco Components for Angular 2
|
# Alfresco Login Component for Angular 2
|
||||||
|
|
||||||
Components included:
|
Components included:
|
||||||
TBD
|
|
||||||
|
* Login Component
|
||||||
|
* Alfresco Authentication Service (TBD)
|
||||||
|
|
||||||
|
### Custom Login Component
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import {Component} from 'angular2/core';
|
||||||
|
import {Login} from 'ng2-alfresco-login/ng2-alfresco-login';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'my-login',
|
||||||
|
template: ' <alfresco-login></alfresco-login>',
|
||||||
|
directives: [Login]
|
||||||
|
})
|
||||||
|
export class MyLoginComponent {
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
|
|||||||
@@ -25,15 +25,30 @@ System.register(['angular2/core', 'rxjs/Rx', 'angular2/http'], function(exports_
|
|||||||
}],
|
}],
|
||||||
execute: function() {
|
execute: function() {
|
||||||
Authentication = (function () {
|
Authentication = (function () {
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param http
|
||||||
|
*/
|
||||||
function Authentication(http) {
|
function Authentication(http) {
|
||||||
this.http = http;
|
this.http = http;
|
||||||
this._host = 'http://192.168.99.100:8080';
|
this._host = 'http://192.168.99.100:8080';
|
||||||
this._baseUrl = this._host + '/alfresco/service/api/';
|
this._baseUrl = this._host + '/alfresco/service/api/';
|
||||||
this.token = localStorage.getItem('token');
|
this.token = localStorage.getItem('token');
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* The method return tru if the user is logged in
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
Authentication.prototype.isLoggedIn = function () {
|
Authentication.prototype.isLoggedIn = function () {
|
||||||
return !!localStorage.getItem('token');
|
return !!localStorage.getItem('token');
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Method to delegate GET or POST login
|
||||||
|
* @param method
|
||||||
|
* @param username
|
||||||
|
* @param password
|
||||||
|
* @returns {Observable<R>|Observable<T>}
|
||||||
|
*/
|
||||||
Authentication.prototype.login = function (method, username, password) {
|
Authentication.prototype.login = function (method, username, password) {
|
||||||
if (method === 'GET') {
|
if (method === 'GET') {
|
||||||
return this.loginGet(username, password);
|
return this.loginGet(username, password);
|
||||||
@@ -42,6 +57,12 @@ System.register(['angular2/core', 'rxjs/Rx', 'angular2/http'], function(exports_
|
|||||||
return this.loginPost(username, password);
|
return this.loginPost(username, password);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* The method provide the login with GET Request
|
||||||
|
* @param username
|
||||||
|
* @param password
|
||||||
|
* @returns {Observable<R>|Observable<T>}
|
||||||
|
*/
|
||||||
Authentication.prototype.loginGet = function (username, password) {
|
Authentication.prototype.loginGet = function (username, password) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var searchParams = new http_1.URLSearchParams();
|
var searchParams = new http_1.URLSearchParams();
|
||||||
@@ -55,6 +76,12 @@ System.register(['angular2/core', 'rxjs/Rx', 'angular2/http'], function(exports_
|
|||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* The method provide the login with POST Request
|
||||||
|
* @param username
|
||||||
|
* @param password
|
||||||
|
* @returns {Observable<R>|Observable<T>}
|
||||||
|
*/
|
||||||
Authentication.prototype.loginPost = function (username, password) {
|
Authentication.prototype.loginPost = function (username, password) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var credentials = '{ username: ' + username + ', password: ' + password + ' }';
|
var credentials = '{ username: ' + username + ', password: ' + password + ' }';
|
||||||
@@ -70,19 +97,30 @@ System.register(['angular2/core', 'rxjs/Rx', 'angular2/http'], function(exports_
|
|||||||
})
|
})
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* The method save the toke in the localStorage
|
||||||
|
* @param jwt
|
||||||
|
*/
|
||||||
Authentication.prototype.saveJwt = function (jwt) {
|
Authentication.prototype.saveJwt = function (jwt) {
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
localStorage.setItem('token', jwt);
|
localStorage.setItem('token', jwt);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* The method remove the token from the local storage
|
||||||
|
* @returns {Observable<T>}
|
||||||
|
*/
|
||||||
Authentication.prototype.logout = function () {
|
Authentication.prototype.logout = function () {
|
||||||
this.token = undefined;
|
this.token = undefined;
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
return Rx_1.Observable.of(true);
|
return Rx_1.Observable.of(true);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* The method write the error in the console browser
|
||||||
|
* @param error
|
||||||
|
* @returns {ErrorObservable}
|
||||||
|
*/
|
||||||
Authentication.prototype.handleError = function (error) {
|
Authentication.prototype.handleError = function (error) {
|
||||||
// in a real world app, we may send the error to some remote logging infrastructure
|
|
||||||
// instead of just logging it to the console
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return Rx_1.Observable.throw(error.json().error || 'Server error');
|
return Rx_1.Observable.throw(error.json().error || 'Server error');
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAOA;gBAMI,wBAAmB,IAAS;oBAAT,SAAI,GAAJ,IAAI,CAAK;oBAHpB,UAAK,GAAU,4BAA4B,CAAC;oBAC5C,aAAQ,GAAU,IAAI,CAAC,KAAK,GAAG,wBAAwB,CAAC;oBAG5D,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC/C,CAAC;gBAED,mCAAU,GAAV;oBACI,MAAM,CAAC,CAAC,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GAAG,CAAC,CAAC;oBACvC,CAAC;gBACL,CAAC;gBAED;;;mBAGG;gBACH,+BAAM,GAAN;oBACI,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;oBACvB,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAEjC,MAAM,CAAC,eAAU,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC/B,CAAC;gBAED;;;;mBAIG;gBACK,oCAAW,GAAnB,UAAoB,KAAc;oBAC9B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBACrB,MAAM,CAAC,eAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,cAAc,CAAC,CAAC;gBAClE,CAAC;gBA9GL;oBAAC,iBAAU,EAAE;;kCAAA;gBA+Gb,qBAAC;YAAD,CAAC,AA9GD,IA8GC;YA9GD,2CA8GC,CAAA"}
|
||||||
@@ -11,14 +11,29 @@ export class Authentication {
|
|||||||
private _host:string = 'http://192.168.99.100:8080';
|
private _host:string = 'http://192.168.99.100:8080';
|
||||||
private _baseUrl:string = this._host + '/alfresco/service/api/';
|
private _baseUrl:string = this._host + '/alfresco/service/api/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param http
|
||||||
|
*/
|
||||||
constructor(public http:Http) {
|
constructor(public http:Http) {
|
||||||
this.token = localStorage.getItem('token');
|
this.token = localStorage.getItem('token');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method return tru if the user is logged in
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return !!localStorage.getItem('token');
|
return !!localStorage.getItem('token');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to delegate GET or POST login
|
||||||
|
* @param method
|
||||||
|
* @param username
|
||||||
|
* @param password
|
||||||
|
* @returns {Observable<R>|Observable<T>}
|
||||||
|
*/
|
||||||
login(method:string, username:string, password:string) {
|
login(method:string, username:string, password:string) {
|
||||||
if (method === 'GET') {
|
if (method === 'GET') {
|
||||||
return this.loginGet(username, password);
|
return this.loginGet(username, password);
|
||||||
@@ -27,6 +42,12 @@ export class Authentication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method provide the login with GET Request
|
||||||
|
* @param username
|
||||||
|
* @param password
|
||||||
|
* @returns {Observable<R>|Observable<T>}
|
||||||
|
*/
|
||||||
loginGet(username:string, password:string) {
|
loginGet(username:string, password:string) {
|
||||||
const searchParams = new URLSearchParams();
|
const searchParams = new URLSearchParams();
|
||||||
searchParams.set('u', username);
|
searchParams.set('u', username);
|
||||||
@@ -41,6 +62,12 @@ export class Authentication {
|
|||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method provide the login with POST Request
|
||||||
|
* @param username
|
||||||
|
* @param password
|
||||||
|
* @returns {Observable<R>|Observable<T>}
|
||||||
|
*/
|
||||||
loginPost(username:string, password:string) {
|
loginPost(username:string, password:string) {
|
||||||
let credentials = '{ username: ' + username + ', password: ' + password + ' }';
|
let credentials = '{ username: ' + username + ', password: ' + password + ' }';
|
||||||
|
|
||||||
@@ -58,12 +85,20 @@ export class Authentication {
|
|||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method save the toke in the localStorage
|
||||||
|
* @param jwt
|
||||||
|
*/
|
||||||
saveJwt(jwt) {
|
saveJwt(jwt) {
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
localStorage.setItem('token', jwt);
|
localStorage.setItem('token', jwt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method remove the token from the local storage
|
||||||
|
* @returns {Observable<T>}
|
||||||
|
*/
|
||||||
logout() {
|
logout() {
|
||||||
this.token = undefined;
|
this.token = undefined;
|
||||||
localStorage.removeItem('token');
|
localStorage.removeItem('token');
|
||||||
@@ -71,9 +106,12 @@ export class Authentication {
|
|||||||
return Observable.of(true);
|
return Observable.of(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method write the error in the console browser
|
||||||
|
* @param error
|
||||||
|
* @returns {ErrorObservable}
|
||||||
|
*/
|
||||||
private handleError(error:Response) {
|
private handleError(error:Response) {
|
||||||
// in a real world app, we may send the error to some remote logging infrastructure
|
|
||||||
// instead of just logging it to the console
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return Observable.throw(error.json().error || 'Server error');
|
return Observable.throw(error.json().error || 'Server error');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './authe
|
|||||||
}],
|
}],
|
||||||
execute: function() {
|
execute: function() {
|
||||||
Login = (function () {
|
Login = (function () {
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param fb
|
||||||
|
* @param auth
|
||||||
|
* @param router
|
||||||
|
*/
|
||||||
function Login(fb, auth, router) {
|
function Login(fb, auth, router) {
|
||||||
this.auth = auth;
|
this.auth = auth;
|
||||||
this.router = router;
|
this.router = router;
|
||||||
@@ -37,15 +43,11 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './authe
|
|||||||
password: ['', common_1.Validators.required]
|
password: ['', common_1.Validators.required]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Login.prototype.isErrorStyle = function (field) {
|
/**
|
||||||
componentHandler.upgradeAllRegistered();
|
* Method called on submit form
|
||||||
if (field.valid) {
|
* @param value
|
||||||
return false;
|
* @param event
|
||||||
}
|
*/
|
||||||
else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Login.prototype.onSubmit = function (value, event) {
|
Login.prototype.onSubmit = function (value, event) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
if (event) {
|
if (event) {
|
||||||
@@ -56,9 +58,23 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', './authe
|
|||||||
_this.error = true;
|
_this.error = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* The method return if a field is valid or not
|
||||||
|
* @param field
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
Login.prototype.isErrorStyle = function (field) {
|
||||||
|
componentHandler.upgradeAllRegistered();
|
||||||
|
if (field.valid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
Login = __decorate([
|
Login = __decorate([
|
||||||
core_1.Component({
|
core_1.Component({
|
||||||
selector: 'login',
|
selector: 'alfresco-login',
|
||||||
moduleId: 'node_modules/ng2-alfresco-login/src/',
|
moduleId: 'node_modules/ng2-alfresco-login/src/',
|
||||||
directives: [router_1.ROUTER_DIRECTIVES, common_1.FORM_DIRECTIVES],
|
directives: [router_1.ROUTER_DIRECTIVES, common_1.FORM_DIRECTIVES],
|
||||||
templateUrl: 'login.component.html',
|
templateUrl: 'login.component.html',
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"login.component.js","sourceRoot":"","sources":["login.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAcA;gBAaI,eAAY,EAAc,EAAS,IAAmB,EAAS,MAAa;oBAAzC,SAAI,GAAJ,IAAI,CAAe;oBAAS,WAAM,GAAN,MAAM,CAAO;oBAX5E,UAAK,GAAW,KAAK,CAAC;oBAYlB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC;wBACjB,QAAQ,EAAE,CAAC,EAAE,EAAE,mBAAU,CAAC,OAAO,CAAC,CAAC,mBAAU,CAAC,QAAQ,EAAE,mBAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBAClF,QAAQ,EAAE,CAAC,EAAE,EAAE,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B;wBAC1B,QAAQ,EAAE,sCAAsC;wBAChD,UAAU,EAAE,CAAC,0BAAiB,EAAE,wBAAe,CAAC;wBAChD,WAAW,EAAE,sBAAsB;wBACnC,SAAS,EAAE,CAAC,qBAAqB,CAAC;qBAErC,CAAC;;yBAAA;gBAiDF,YAAC;YAAD,CAAC,AAhDD,IAgDC;YAhDD,yBAgDC,CAAA"}
|
||||||
@@ -5,7 +5,7 @@ import {Authentication} from './authentication.service';
|
|||||||
declare let componentHandler;
|
declare let componentHandler;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'login',
|
selector: 'alfresco-login',
|
||||||
moduleId: 'node_modules/ng2-alfresco-login/src/',
|
moduleId: 'node_modules/ng2-alfresco-login/src/',
|
||||||
directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES],
|
directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES],
|
||||||
templateUrl: 'login.component.html',
|
templateUrl: 'login.component.html',
|
||||||
@@ -16,15 +16,12 @@ export class Login {
|
|||||||
form:ControlGroup;
|
form:ControlGroup;
|
||||||
error:boolean = false;
|
error:boolean = false;
|
||||||
|
|
||||||
isErrorStyle(field:ControlGroup) {
|
/**
|
||||||
componentHandler.upgradeAllRegistered();
|
* Constructor
|
||||||
if (field.valid) {
|
* @param fb
|
||||||
return false;
|
* @param auth
|
||||||
} else {
|
* @param router
|
||||||
return true;
|
*/
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(fb:FormBuilder, public auth:Authentication, public router:Router) {
|
constructor(fb:FormBuilder, public auth:Authentication, public router:Router) {
|
||||||
this.form = fb.group({
|
this.form = fb.group({
|
||||||
username: ['', Validators.compose([Validators.required, Validators.minLength(4)])],
|
username: ['', Validators.compose([Validators.required, Validators.minLength(4)])],
|
||||||
@@ -32,6 +29,11 @@ export class Login {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called on submit form
|
||||||
|
* @param value
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
onSubmit(value:any, event) {
|
onSubmit(value:any, event) {
|
||||||
if (event) {
|
if (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -44,4 +46,18 @@ export class Login {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method return if a field is valid or not
|
||||||
|
* @param field
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isErrorStyle(field:ControlGroup) {
|
||||||
|
componentHandler.upgradeAllRegistered();
|
||||||
|
if (field.valid) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user