Skip to content

Commit

Permalink
fixed bug where new users could not add beer
Browse files Browse the repository at this point in the history
  • Loading branch information
Geertvdc committed Oct 14, 2019
1 parent 871ccaf commit a686e4d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FridgeService } from 'src/app/services/fridge.service';
import { Beer } from 'src/app/model/beer';
import { Router } from '@angular/router';
import { BeerAddition } from 'src/app/model/beerAddition';
import { MsalService } from '@azure/msal-angular';

@Component({
selector: 'app-add-beer',
Expand All @@ -13,7 +14,7 @@ import { BeerAddition } from 'src/app/model/beerAddition';
export class AddBeerComponent implements OnInit {

angForm: FormGroup;
constructor(private fb: FormBuilder, private fridgeService: FridgeService, private router: Router) {
constructor(private fb: FormBuilder, private fridgeService: FridgeService, private router: Router, private msal: MsalService) {
this.createForm();
}

Expand All @@ -33,6 +34,11 @@ export class AddBeerComponent implements OnInit {

ngOnInit() {
this.fridgeService.getFridgeUsers().subscribe((users: Array<string>) => {
var currentUser = this.msal.getUser();
if(!users.find(u =>u == currentUser.name))
{
users.unshift(currentUser.name);
}
this.users = users;
});

Expand Down

0 comments on commit a686e4d

Please sign in to comment.