Skip to content

Commit 22cdb58

Browse files
committed
Merge pull request #16 from sherrla/master
updated logic for access
2 parents 3109dd2 + 2bedc96 commit 22cdb58

1 file changed

Lines changed: 25 additions & 17 deletions

File tree

admin.rb

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
require 'pry'
22

3-
#you run a site that offers a matching service between vendors selling laptops and customers
4-
#..looking to purchase; you charge a fee to be listed as a vendor
5-
#your site's users must sign in and if they are an admin they are able to make changes to the site
3+
def user_permission
64

7-
########################################################
5+
puts "did you pay your bills? (yes/no)"
6+
paid = gets.strip
87

9-
#write a function "user_permission" that accepts four parameters: signed_in, admin, paid, and canceled
8+
puts "did you cancel"
9+
canceled = gets.strip
1010

11-
#ask the user if they pay their bills (yes/no)
12-
#store their answer in a variable
11+
puts "are you an admin"
12+
admin = gets.strip
1313

14-
#ask the user if they have canceled a deal (yes/no)
15-
#store their answer in a variable
14+
puts "are you signed in"
15+
signed_in = gets.strip
1616

17-
#ask the user if they are an admin (yes/no)
18-
#store their answer in a variable
1917

20-
#ask the user if they are signed in (yes/no)
21-
#store their answer in a variable
18+
if paid == "no" or canceled == "yes"
19+
puts "go away"
2220

23-
#if the user doesn't pay their bills or has canceled a deal, show "go away!"
24-
#if the user is signed in and they are an admin, show "you can see see and change all the pages!"
25-
#if you user is signed in but they are not an admin, show "you can see all the pages!"
26-
#if the user is not signed in, show "you can't see any of the pages, please sign in!"
2721

22+
elsif signed_in == "yes" and admin == "yes"
23+
puts "you can see and change all the pages"
24+
25+
26+
elsif signed_in == "yes" and admin == "no"
27+
puts "you can see all the pages"
28+
29+
elsif signed_in == "no"
30+
puts "you can't see any of the pages, please sign in"
31+
else
32+
"sorry charlie"
33+
end
34+
end
35+
user_permission
2836

2937

3038
# call the function

0 commit comments

Comments
 (0)