Skip to content
Browse files

Done with basic authentication

  • Loading branch information...
1 parent 2d3743a commit e3390d56cdef22d6d0be3b8b453417deb85b2a55 Jarek Plonski committed
View
1 .idea/modules.xml
@@ -3,6 +3,7 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Meetings_with_Google.iml" filepath="$PROJECT_DIR$/.idea/Meetings_with_Google.iml" />
+ <module fileurl="file://$PROJECT_DIR$/.idea/Meetings_with_Google.iml" filepath="$PROJECT_DIR$/.idea/Meetings_with_Google.iml" />
</modules>
</component>
</project>
View
2 app/controllers/sessions_controller.rb
@@ -3,7 +3,7 @@ def new
end
def create
- sign_in User.find_user(params[:session][:user_id])
+ sign_in( User.find_user(params[:session][:user_id]) )
puts "!!! create " + params[:session][:user_id].inspect.to_s
redirect_to users_path
end
View
2 app/helpers/sessions_helper.rb
@@ -10,7 +10,7 @@ def signed_in?
def admin?
User.find(session[:user_id]).name.eql?("Admin")
- end
+end
def current_user(user_id)
session[:user_id] == user_id
View
8 app/models/meeting.rb
@@ -128,6 +128,14 @@ def ends_at_param_builder(params)
params
end
+ def self.places
+ places = []
+ Meeting.all.each do |meeting|
+ places << meeting.place
+ end
+ places.uniq
+ end
+
### Validations
View
5 app/views/layouts/application.html.haml
@@ -6,6 +6,11 @@
= javascript_include_tag :defaults
= csrf_meta_tag
%body
+ - if !(controller.controller_name.eql?("sessions"))
+ - if !signed_in?
+ = link_to "Sign in", signin_path
+ - else
+ %p Logged in as #{User.find(session[:user_id]).name} #{link_to "Sign out" ,signout_path}
= yield
= debug(params) if Rails.env.development?
-if Rails.env.development?
View
2 app/views/sessions/new.html.haml
@@ -6,7 +6,7 @@
= f.label :email
- = f.select :user_id, options_from_collection_for_select(User.all, 'id', 'email')
+ = f.select :user_id, options_from_collection_for_select(User.all, 'id', 'email', params[:user_id])
= f.submit "Sign in"
View
1 app/views/shared/_form_for_meeting.html.haml
@@ -20,6 +20,7 @@
= f.text_area :description
.field
= f.label :place
+ = f.select :place, options_for_select(Meeting.places, :place )
= f.text_field :place
.field
= f.label :total_places
View
2 app/views/shared/_users_list.html.haml
@@ -1,7 +1,6 @@
%table
%tr
%th Name
- %th ID
%th Email
%th
%th
@@ -10,7 +9,6 @@
- @users.each do |user|
%tr
%td= user.name
- %td= user.id
%td= user.email
- if admin?
%td= link_to 'Show', user
View
3 app/views/users/index.html.haml
@@ -6,4 +6,5 @@
%br
-= link_to 'New User', new_user_path
+- if admin?
+ = link_to 'New User', new_user_path

0 comments on commit e3390d5

Please sign in to comment.
Something went wrong with that request. Please try again.