Skip to content

Instantly share code, notes, and snippets.

@ivan-hilckov
Created July 26, 2012 12:46
Show Gist options
  • Select an option

  • Save ivan-hilckov/3181837 to your computer and use it in GitHub Desktop.

Select an option

Save ivan-hilckov/3181837 to your computer and use it in GitHub Desktop.
model_openid
# # Openid Model
# Валидирует и отправляет форму на сервер
class Elections.Model.Openid extends Elections.Model.Base
url: "/auth/open_id"
validation:
openid_url: [{
required: true
pattern: /^(https?:\/\/)?([\w\.]+)\.([a-z]{2,6}\.?)(\/[\w\.]*)*\/?$/
msg: "Введите OpenID"
}]
save: ->
xhr = @always( super )
return xhr
always: ( xhr ) ->
console.log "always==>", xhr
xhr.always =>
switch xhr.status
when 422
if JSON.parse( xhr.responseText ).error_type is "connection_failed"
@.trigger "invalid", "openid_url", "Неверный OpenID"
return xhr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment