コード例 #1
0
        public async Task<IHttpActionResult> CheckUsernameAvailability(RecoveryEmailDTO data)
        {
            bool check = false;
            Student stu = await db.Students.Where(c => c.email == data.username).SingleOrDefaultAsync();
            Company comp = await db.Companies.Where(d => d.email == data.username).SingleOrDefaultAsync();
            if (stu != null)
            {
                check = true;
            }
            if (comp != null)
            {
                check = true;
            }

            if (check)
            {
                return StatusCode(HttpStatusCode.NotAcceptable);
            }
            else
            {
                return Ok();
            }
        }
コード例 #2
0
        public async Task<IHttpActionResult> password_token(RecoveryEmailDTO data)
        {
            //ApplicationUser user = await admin.Users.Where(b => b.UserName == username).SingleOrDefaultAsync();
            string user_id ="";
            Student stu = await db.Students.Where(c => c.email == data.username).SingleOrDefaultAsync();
            Company comp = await db.Companies.Where(d => d.email == data.username).SingleOrDefaultAsync();
            if (stu != null)
            {
                user_id = stu.registrationId;
            }
            if (comp != null){
                user_id = comp.registrationId;
            }

            if (user_id == "")
            {
                return StatusCode(HttpStatusCode.NotFound);
            }
            
            string code = await UserManager.GeneratePasswordResetTokenAsync(user_id);

            return Ok(new RecoveryDTO { passwordRecoveryToken= code});
        }