Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onSubmit(name: string, pass:string): void {
- name = name.trim();
- if (!name) { return; }
- let user: any = {
- name: null,
- pass: null
- };
- user.name = {value: name};
- user.pass = { "": pass};
- console.log('Json from the form ' +JSON.stringify(user));
- this.UserService.login(user)
- .subscribe(user => {
- console.log('subscribed to login function' + JSON.stringify(this.user));
- });
- }
- login (user: User): Observable<User> {
- const url = `${this.mainUrl}/user/login?_format=json`;
- const postReturn = this.http.post(url, user, httpHaljson);
- console.log('Login return from the user service' + JSON.stringify(postReturn));
- return postReturn
- }
- const httpHaljson = {
- headers: new HttpHeaders({
- "X-CSRF-Token": "Qfnczb1SUnvOAsEy0A_xuGp_rkompgO2oTkCBOSEItM",
- "Authorization": "Basic Qfnczb1SUnvOAsEy0A_xuGp_rkompgO2oTkCBOSEItM", // encoded user/pass - this is admin/123qwe
- // "Content-Type": "application/hal+json"
- "Content-Type": "application/json"
- })
- };
- {"_isScalar":false,"source":{"_isScalar":false,"source":
- {"_isScalar":false,"source":{"_isScalar":true,"value":
- {"url":"http://drupal.dd:8083/user/login?_format=json","body":{"name":
- {"value":"asd"},"pass":
- {"":"123"}},"reportProgress":false,"withCredentials":false,"responseType":"
- json","method":"POST","headers":{"normalizedNames":
- {},"lazyUpdate":null},"params":{"updates":null,"cloneFrom":null,"encoder":
- {},"map":null},"urlWithParams":"http://drupal.dd:8083/user/login?
- _format=json"},"scheduler":null},"operator":{"concurrent":1}},"operator":
- {}},"operator":{}}
Add Comment
Please, Sign In to add comment