Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Startup
- {
- public void Configuration(IAppBuilder app)
- {
- app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
- HttpConfiguration config = new HttpConfiguration();
- ConfigureAuth(app);
- ConfigAutoMapper();
- WebApiConfig.Register(config);
- app.UseWebApi(config);
- }
- }
- public SetToken(eMail : string, password : string) : BehaviorSubject<string>{
- let data = `grant_type=password&username=${eMail}&password=${password}`;
- axios.post('http://localhost:12685/token', data , { headers: { 'Content-Type' : 'application/x-www-form-urlencoded'} })
- .then(response => {
- this.token = response.data.access_token;
- this.$token.next(this.token);
- let item = {
- 'eMail' : eMail,
- 'token' : this.token
- }
- localStorage.setItem("user", JSON.stringify(item));
- this.eMail = eMail;
- this.$eMail.next(this.eMail);
- })
- .catch(error => {
- console.log(error);
- });
- return this.$token;
- }
Add Comment
Please, Sign In to add comment