ruby on rails - implmenting custom authentication with devise, 'mapping' member -


i'm trying write custom (remote) authentication devise. api doc i've found this example, i'm proceding trials , errors.


i'm particulary interested in understanding 'mapping.to.new' line do.

it seems crucial since if returns nil, authentication process fail.

but "mappings", defined?

furthermore, call

 mapping.to.new 

has strange, seems object instantiation... isn't it?

i've found different implementation, looks like:

resource = mapping.to.where(["username = ?", auth_params[:username]]).first 

where seems mapping.to returns relation object, again, expected define mappings are?

  class remoteauthenticatable < authenticatable     def authenticate!       auth_params = authentication_hash       auth_params[:password] = password        resource = mapping.to.new        return fail! unless resource        if validate(resource){ resource.remote_authentication(auth_params) }         success!(resource)       end     end   end 

mapping.to instance class of model on map authentification ( user or admin). if call mapping.to.new same call user.new. , if call mapping.to.where(...) return same result user.where(...).

more can find on mapping.rb


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -