title: login from Realtime firebase database without authentication
body: <p>Please help me to log in from the Realtime firebase database without authentication. I want to fetch key and compare the password to the user input password.</p>
  
  <p>I have attached some code please review me.</p>
  
  <p>loginComponent.html</p>
  
  <pre><code>&lt;div class="form-group"&gt;
                  &lt;input type="text" id="empid" [(ngModel)]="empid" class="form-control m-2" placeholder="Employee Id"&gt;
              &lt;/div&gt;
              &lt;div class="form-group" *ngIf="!isForgotPassword"&gt;
                  &lt;input type="password" class="form-control m-2" [(ngModel)]="passwordInput" placeholder="Password" id="password"&gt;
              &lt;/div&gt;
              &lt;div class="form-group" *ngIf="!isForgotPassword"&gt;
              &lt;span *ngIf="selectedVal == 'login'; else elseBlock"&gt;
                  &lt;button type="button" class="btn btn-orange btn-block m-2" (click)="loginUser()"&gt;Login&lt;/button&gt;
              &lt;/span&gt;
  </code></pre>
  
  <p></p>
  
  <p>loginComponent.ts</p>
  
  <pre><code> emailInput: string;
   passwordInput: string;
   isForgotPassword: boolean;
   empId : string;
   userDetails: any;
  
  constructor(
   private userService: UserService,
   private router: Router
  ) {
   this.selectedVal = 'login';
   this.isForgotPassword = false;
  }
  
  loginUser(){
    this.userService.login(this.empId, this.passwordInput);
  }
  </code></pre>
  
  <p>UserService.ts</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { AngularFireDatabase} from 'angularfire2/database';
  import { User } from '../user.model'
  import { Router } from '@angular/router';
  import * as firebase from 'firebase';
  
  @Injectable({
    providedIn: 'root'
    })
   export class UserService {
    user : User[];
    ref = 'Batch'
    batch = 'DEC2019'
  
    constructor(
       public af: AngularFireDatabase,
       public router: Router
    ) { }
  
    login(empId: string, password: string){
       return this.af.database.ref('Users/').child(empId).once('value')
      .then(snapshot=&gt;{ 
  
     })
     .catch(err =&gt;{
       console.log('Something went wrong',err.message)
     })
   }
  </code></pre>