Last active
December 20, 2015 21:29
-
-
Save abhishek0/6197730 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoginController < ApplicationController | |
skip_before_filter :check_authentication, :only => :index | |
def index | |
@user = User.find_by_email(params[:email]) | |
if @user && @user.authenticate(params[:password]) | |
render 'login/index' | |
else | |
record_not_found | |
end | |
end | |
private | |
def login_params | |
params.require(:login).permit(:email, :password) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
def index | |
@users = User.all | |
end | |
def create | |
@user = User.new(user_params) | |
@user.password = 'lallu' | |
@user.password_confirmation = 'lallu' | |
@user.parent = @current_user | |
logger.info @user.inspect | |
unless @user.valid? and @user.save | |
bad_request | |
end | |
end | |
private | |
def user_params | |
params.require(:user).permit(:first_name, :mobile_number, :email, :locality, :city, :user_type) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment