Skip to content

Commit

Permalink
otherwise routing added
Browse files Browse the repository at this point in the history
  • Loading branch information
ChauhanAbhinav committed Sep 6, 2019
1 parent a08c668 commit 1b65067
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login/login.component'
import { LoginComponent } from './login/login.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { PublicComponent } from './public/public.component';
import { PrivateComponent } from './private/private.component';
Expand All @@ -25,7 +25,8 @@ const routes: Routes = [
{ path: 'grouplist', component: GroupListComponent },
{ path: 'edit', component: EditComponent },
]
}
},
{ path: '**', component: LoginComponent },
];

@NgModule({
Expand Down
1 change: 1 addition & 0 deletions src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class LoginComponent implements OnInit {
countryCode: ['+91', [Validators.required]],
});
constructor(private fb: FormBuilder, private loginService: LoginService) {
loginService.authenticate();
}

onSubmit() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/private/private.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class PrivateComponent implements OnInit, AfterViewInit {
}
private sendMessage(event) {
if (event.which === 13 && this.input !== '') {
const messageId = Math.round(Math.random() * 10);
const messageId = Math.round(Math.random() * 10000000);
this.socket.emit('sendchat', this.loginService.user, this.contact, this.room, this.input, messageId);
this.input = '';
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/login.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export class LoginService {
}
login(mobile) {
this.cookieService.set( 'user', mobile, 1, '/'); // take mobile as string, expires in 1 days
this.router.navigateByUrl('/dashboard');
this.user = mobile;
this.name = this.getLoggedName(mobile);
this.router.navigateByUrl('/dashboard');
}
getLoggedUser() {
const cookieExists: boolean = this.cookieService.check('user');
Expand Down

0 comments on commit 1b65067

Please sign in to comment.