diff options
author | Fatih Acet <acetfatih@gmail.com> | 2018-02-05 17:43:16 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2018-02-05 17:43:16 +0300 |
commit | 3cb7b472cd834dcd67142bb25599af3872628bbf (patch) | |
tree | 64390f21dd0301bffd242c0926a3a84f4d7990f9 /app | |
parent | 9edd95658308f3e0e8e6df6eb829555a3cb418d1 (diff) | |
parent | 0ba3e84fe4845d1dbc02271dfe97a51968f2bd22 (diff) |
Merge branch 'axios-username-validator' into 'master'
Replace $.ajax in username validator with axios
See merge request gitlab-org/gitlab-ce!16892
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/pages/sessions/new/username_validator.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/assets/javascripts/pages/sessions/new/username_validator.js b/app/assets/javascripts/pages/sessions/new/username_validator.js index bb34d5d2008..745543c22da 100644 --- a/app/assets/javascripts/pages/sessions/new/username_validator.js +++ b/app/assets/javascripts/pages/sessions/new/username_validator.js @@ -1,6 +1,9 @@ /* eslint-disable comma-dangle, consistent-return, class-methods-use-this, arrow-parens, no-param-reassign, max-len */ import _ from 'underscore'; +import axios from '~/lib/utils/axios_utils'; +import flash from '~/flash'; +import { __ } from '~/locale'; const debounceTimeoutDuration = 1000; const invalidInputClass = 'gl-field-error-outline'; @@ -77,12 +80,9 @@ export default class UsernameValidator { this.state.pending = true; this.state.available = false; this.renderState(); - return $.ajax({ - type: 'GET', - url: `${gon.relative_url_root}/users/${username}/exists`, - dataType: 'json', - success: (res) => this.setAvailabilityState(res.exists) - }); + axios.get(`${gon.relative_url_root}/users/${username}/exists`) + .then(({ data }) => this.setAvailabilityState(data.exists)) + .catch(() => flash(__('An error occurred while validating username'))); } } |