示例#1
0
        public async Task <ActionResult> Register(Account account)
        {
            if (string.IsNullOrEmpty(account.Email) || string.IsNullOrEmpty(account.Password))
            {
                return(StatusCode((int)HttpStatusCode.BadRequest,
                                  Json(new { error = "Email or Password are required" })));
            }

            var dbAccount = await _accountCollection.FindAsync(account.Email, "account-email");

            if (dbAccount != null)
            {
                return(StatusCode((int)HttpStatusCode.BadRequest, Json(new { error = "Account already exists" })));
            }

            var salt = BCrypt.Net.BCrypt.GenerateSalt();

            var hashedPassword = _cryptoService.PasswordCrypt(account.Password, salt);

            account = new Account
            {
                Email        = account.Email,
                Password     = hashedPassword,
                PasswordSalt = salt
            };

            dbAccount = await _accountCollection.AddOrUpdateAsync(account);

            dbAccount.Password     = string.Empty;
            dbAccount.PasswordSalt = string.Empty;

            return(StatusCode((int)HttpStatusCode.OK, Json(dbAccount)));
        }
        public void SetupTests()
        {
            var settingsCollection = new CouchDbStore <ApplicationSettings>(ApplicationSettings.CouchDbUrl);
            var settings           = settingsCollection.FindAsync("9c3131ee7b9fb97491e8551211495381").GetAwaiter().GetResult();

            _seClient = new StreamElementsService(settings);
        }
示例#3
0
        public void SetupTests()
        {
            //TODO: Put default couchdburl in appsettings and transform during CI/CD
            var settingsCollection = new CouchDbStore <ApplicationSettings>(ApplicationSettings.CouchDbUrl);
            var settings           = settingsCollection.FindAsync("9c3131ee7b9fb97491e8551211495381").GetAwaiter().GetResult();

            _seClient = new StreamElementsService(settings);
        }
示例#4
0
        public void SetUpTests()
        {
            var settingsCollection = new CouchDbStore <ApplicationSettings>(ApplicationSettings.CouchDbUrl);
            var settings           = settingsCollection.FindAsync("9c3131ee7b9fb97491e8551211495381").GetAwaiter().GetResult();

            _vodCollection = new CouchDbStore <Vod>(ApplicationSettings.CouchDbUrl);
            _twitchService = new TwitchService(settings);
        }
        public async Task <ActionResult> Get(string id)
        {
            Account account;

            try
            {
                account = await _accountCollection.FindAsync(id);

                account.Password     = string.Empty;
                account.PasswordSalt = string.Empty;
            }
            catch (Exception e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, Json(e)));
            }

            return(StatusCode((int)HttpStatusCode.OK, Json(account)));
        }