Guest User

Untitled

a guest
Aug 22nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. public partial class Startup
  2. {
  3. public void Configuration(IAppBuilder app)
  4. {
  5. app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
  6.  
  7. HttpConfiguration config = new HttpConfiguration();
  8.  
  9. ConfigureAuth(app);
  10. ConfigAutoMapper();
  11.  
  12. WebApiConfig.Register(config);
  13. app.UseWebApi(config);
  14. }
  15. }
  16.  
  17. public SetToken(eMail : string, password : string) : BehaviorSubject<string>{
  18. let data = `grant_type=password&username=${eMail}&password=${password}`;
  19. axios.post('http://localhost:12685/token', data , { headers: { 'Content-Type' : 'application/x-www-form-urlencoded'} })
  20. .then(response => {
  21. this.token = response.data.access_token;
  22. this.$token.next(this.token);
  23.  
  24. let item = {
  25. 'eMail' : eMail,
  26. 'token' : this.token
  27. }
  28.  
  29. localStorage.setItem("user", JSON.stringify(item));
  30.  
  31. this.eMail = eMail;
  32. this.$eMail.next(this.eMail);
  33. })
  34. .catch(error => {
  35. console.log(error);
  36. });
  37.  
  38. return this.$token;
  39. }
Add Comment
Please, Sign In to add comment