Guest User

Untitled

a guest
Mar 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. function insertUser(
  2. address userAddress,
  3. bytes32 userEmail,
  4. string userName)
  5. public
  6. returns(uint index) {
  7. if (isUser(userAddress)) revert();
  8. userObjects[userAddress].userEmail = userEmail;
  9. userObjects[userAddress].userName = userName;
  10. userObjects[userAddress].index = userIndex.push(userAddress)-1;
  11. LogNewUser(
  12. userAddress,
  13. userObjects[userAddress].index,
  14. userEmail,
  15. userName);
  16. return userIndex.length-1;
  17. }
  18.  
  19. register(address: string): Observable<any> {
  20. return Observable.create(observer => {
  21. this.auth.deployed().then(instance => {
  22. console.log('add=>', address, 'insertion')
  23. return instance.insertUser(address, 'something', 'something');
  24. })
  25. .then(numberOfUsers => {
  26. observer.next();
  27. })
  28. .catch(e => {
  29. console.log(e);
  30. observer.error(e);
  31. });
  32. });
  33. }
  34.  
  35. this.web3Service.getAccounts().subscribe(accs => {
  36. this.account = accs[0];
  37. this._ngZone.run(() =>
  38.  
  39. );
  40. }, err => alert(err));
  41. this.authService.register(this.account).subscribe(data => {
  42. console.log(data);
  43. });
Add Comment
Please, Sign In to add comment