|
20 | 20 | using Microsoft.AspNetCore.Authentication.JwtBearer;
|
21 | 21 | using Microsoft.IdentityModel.Tokens;
|
22 | 22 | using System.Text;
|
| 23 | +using Backend.DTOs; |
23 | 24 |
|
24 | 25 | namespace Backend
|
25 | 26 | {
|
@@ -85,7 +86,7 @@ public void ConfigureServices(IServiceCollection services)
|
85 | 86 | }
|
86 | 87 |
|
87 | 88 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
88 |
| - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
| 89 | + public async void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
89 | 90 | {
|
90 | 91 | using (var scope = app.ApplicationServices.CreateScope())
|
91 | 92 | {
|
@@ -114,6 +115,110 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
114 | 115 | endpoints.MapControllers();
|
115 | 116 | });
|
116 | 117 |
|
| 118 | + |
| 119 | + using (var scope = app.ApplicationServices.CreateScope()) |
| 120 | + { |
| 121 | + var authService = scope.ServiceProvider.GetRequiredService<IAuthenticationService>(); |
| 122 | + |
| 123 | + if (!authService.UserExists("22002900", "oisep@bilkent.edu.tr").GetAwaiter().GetResult()) |
| 124 | + { |
| 125 | + authService.Register(new DTOs.RegisterDto |
| 126 | + { |
| 127 | + ActorType = "Office of International Students and Exchange Programs", |
| 128 | + UserName = "22002900", |
| 129 | + Email = "oisep@bilkent.edu.tr", |
| 130 | + Password = "Test123_", |
| 131 | + FirstName = "Erkin", |
| 132 | + LastName = "Tarhan", |
| 133 | + } |
| 134 | + ).Wait(); |
| 135 | + } |
| 136 | + |
| 137 | + if (!authService.UserExists("22002901", "instructor@bilkent.edu.tr").GetAwaiter().GetResult()) |
| 138 | + { |
| 139 | + authService.Register(new DTOs.RegisterDto |
| 140 | + { |
| 141 | + ActorType = "Course Coordinator Instructor", |
| 142 | + UserName = "22002901", |
| 143 | + Email = "instructor@bilkent.edu.tr", |
| 144 | + Password = "Test123_", |
| 145 | + FirstName = "Eray", |
| 146 | + LastName = "Tüzün", |
| 147 | + Department = new DTOs.DepartmentInfoDto |
| 148 | + { |
| 149 | + DepartmentName = "Department of Computer Engineering", |
| 150 | + FacultyName = "Faculty of Engineering", |
| 151 | + } |
| 152 | + }).Wait(); |
| 153 | + } |
| 154 | + |
| 155 | + if (!authService.UserExists("1", "admin@bilkent.edu.tr").GetAwaiter().GetResult()) |
| 156 | + { |
| 157 | + authService.Register(new DTOs.RegisterDto |
| 158 | + { |
| 159 | + ActorType = "Admin", |
| 160 | + UserName = "1", |
| 161 | + Email = "admin@bilkent.edu.tr", |
| 162 | + Password = "Test123_", |
| 163 | + FirstName = "Edward", |
| 164 | + LastName = "Snowden" |
| 165 | + }).Wait(); |
| 166 | + } |
| 167 | + |
| 168 | + if (!authService.UserExists("22002902", "coordinator@bilkent.edu.tr").GetAwaiter().GetResult()) |
| 169 | + { |
| 170 | + authService.Register(new DTOs.RegisterDto |
| 171 | + { |
| 172 | + ActorType = "Exchange Coordinator", |
| 173 | + UserName = "22002902", |
| 174 | + Email = "coordinator@bilkent.edu.tr", |
| 175 | + Password = "Test123_", |
| 176 | + FirstName = "Can", |
| 177 | + LastName = "Alkan", |
| 178 | + Department = new DTOs.DepartmentInfoDto |
| 179 | + { |
| 180 | + DepartmentName = "Department of Computer Engineering", |
| 181 | + FacultyName = "Faculty of Engineering", |
| 182 | + } |
| 183 | + }).Wait(); |
| 184 | + } |
| 185 | + |
| 186 | + if (!authService.UserExists("22002903", "dean@bilkent.edu.tr").GetAwaiter().GetResult()) |
| 187 | + { |
| 188 | + authService.Register(new DTOs.RegisterDto |
| 189 | + { |
| 190 | + ActorType = "Dean Department Chair", |
| 191 | + UserName = "22002903", |
| 192 | + Email = "dean@bilkent.edu.tr", |
| 193 | + Password = "Test123_", |
| 194 | + FirstName = "Nail", |
| 195 | + LastName = "Akar", |
| 196 | + Department = new DTOs.DepartmentInfoDto |
| 197 | + { |
| 198 | + DepartmentName = "Department of Computer Engineering", |
| 199 | + FacultyName = "Faculty of Engineering", |
| 200 | + } |
| 201 | + }).Wait(); |
| 202 | + } |
| 203 | + |
| 204 | + if (!authService.UserExists("22002904", "chair@bilkent.edu.tr").GetAwaiter().GetResult()) |
| 205 | + { |
| 206 | + authService.Register(new DTOs.RegisterDto |
| 207 | + { |
| 208 | + ActorType = "Dean Department Chair", |
| 209 | + UserName = "22002904", |
| 210 | + Email = "chair@bilkent.edu.tr", |
| 211 | + Password = "Test123_", |
| 212 | + FirstName = "Selim", |
| 213 | + LastName = "Aksoy", |
| 214 | + Department = new DTOs.DepartmentInfoDto |
| 215 | + { |
| 216 | + DepartmentName = "Department of Computer Engineering", |
| 217 | + FacultyName = "Faculty of Engineering", |
| 218 | + } |
| 219 | + }).Wait(); |
| 220 | + } |
| 221 | + } |
117 | 222 | }
|
118 | 223 | }
|
119 | 224 | }
|
0 commit comments