ga-wdi-boston / team-project

Other
2 stars 39 forks source link

administrator feature for CMS prompt #330

Closed awoodrum87 closed 7 years ago

awoodrum87 commented 7 years ago

I am attempting to add a feature implementing an admin feature.

The stories are:

  1. As an admin I want to be able delete blogs for all users
  2. As an admin I want to be able to update blogs for all users

My approach:

  1. update users schema to include an isAdmin field (boolean) 1.1 this works in curl and on the front end. Yay
  2. In app/controllers/concerns duplicate the authenticate.js and modify it to authenticate an admin 2.1 I tried this and while I have no errors, I am not sure if it actually works
  3. In app/controllers/... set a before_action that authenticates an admin and write an adminUpdate and adminDestroy function 3.1 this doesn't work. The admin cannot destroy or update a post or page that isn't owned by that user. The error is a 404 error. I'm not comfortable enough in Express api to trouble shoot this and isolate where the error is.

I need guidance on if this approach is a dead end. If not, I need a little help isolating my error (sort of like console.log in the client code)

Thanks!

jordanallain commented 7 years ago

did you customize the authentication method so that it checks that isAdmin field? can you paste in some relevant code?

jordanallain commented 7 years ago

@awoodrum87 can you close if you don't need assistance with this anymore?

awoodrum87 commented 7 years ago

No problem