summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-02-21 12:31:50 -0700
committermo khan <mo@mokhan.ca>2015-02-21 12:31:50 -0700
commit6ada62adfd2b60e3af4f721ed8e09a5658920fa6 (patch)
tree1f65086944ce3be9b12b48bda16761fde6a6b965 /app/controllers
parentd3f91de6fcc6d27bc2d7adb8f1e14d73b71e7b96 (diff)
add user model and login page.
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/sessions_controller.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
new file mode 100644
index 0000000..baf8679
--- /dev/null
+++ b/app/controllers/sessions_controller.rb
@@ -0,0 +1,17 @@
+class SessionsController < ApplicationController
+ def new
+ @user = User.new
+ end
+
+ def create
+ user = User.find_by(username: user_params[:username])
+ if user && user.authenticate(user_params[:password])
+ session[:x] = user.id
+ redirect_to agents_path
+ end
+ redirect_to new_session_path
+ end
+
+ def destroy
+ end
+end