User admin page #48
Comments
this is where i run into some trouble as I need to understand the moleculer framework and how the Devices (and Users) page is supposed to be used. it seems that you want to have your user admin panel visible on the same front end as the normal client? does the Devices page just log all users? this will be interesting.. I won't work on this right now as I have a couple of things to clear but I will notify when I start work on this. |
It will be an admin page which only visible for admins. Currently there is no page filtering in client side, but I will add it to the router. |
gotcha, i'm still traveling right now (been a loong trip) but should be available to start work on this this weekend. :) |
starting work |
Thanks! |
OK my main problem with adapting #Problem 1
#Problem 2 |
just a note to self, the new |
ok @icebob please have a look at https://github.com/sw-yx/vue-express-mongo-boilerplate/tree/ice-services. I have added all the requested items but I have not created a PR because there is something seriously wrong with the rendering when I do chrome console doesnt report any errors. Any idea what is going on? In general i think there is some serious compatibility issues going on with the dependencies in ice-services. If you just try a fresh install of ice-services, you can |
I will check these issues |
When you developing use |
ok i was not using
i have since changed the
and now it runs fine. |
ok so now the UI works and I am testing the functionality. for Updating and Deleting users this thing works. however for creating users, because of the limited set of fields we expose, the validation fails because we dont offer a password field. how do you think about this? there are a few options
we also need to figure out how to represent smaller issue but let me know what the hungarian i18ns are for these words:
i have committed the latest working version to https://github.com/sw-yx/vue-express-mongo-boilerplate/tree/ice-services (includes your PR to fix the webpack issue) |
Great! About password I think the best solution is that in admin page we can't set password. On server side ( Problem 1: you can copy the nested graphql schema from "applogic/profile/service.js". Please don't care with hungarian translation. I will fill it after merge. Btw, please remove sensitive fields from "modelPropFilter" in users service. modelPropFilter: "code fullName email username passwordLess provider profile socialLinks roles verified apiKey lastLogin locale status createdAt updatedAt" |
awesome. separate, potential small issue: vs
i am leaving this unresolved for now until i can figure out if this matters. (i'm a complete graphql newbie so i am sticking very close to the |
ok i think I am at my last 2 problems. #1 I am still unable to create user without password because the password validation throws an error. i have worked around this by generating a dummy password so i can save the new User but it feels very hacky. this is a small problem we dont really have to deal with it until later. #2 I cannot render the password reset email like you do normally because i dont have access to |
#1 I think this solution is good. I'm using same method when user sign-up a passwordless account. So it's correct. #2 the mail template is a pug file. So you can render it with pug instead of req.render. I think the |
ok awesome. so the only remaining issues i have are all to do with the pug rendering and mail sending. I may not have the knowledge to finish this final step but maybe I am missing something. #1: i18n is normally provided through #2: backlink is normally provided through #3:
which shows it is taking the filename instead of the filepath. so doing something like the example set seems impossible. i looked thru pug's docs and there doesnt seem to be a way to resolve filepaths from within pug, except maybe with the resolve api. #4: smaller issue - we use
warning everywhere. I am continuing to use phew, that's a lot of errors all close together! basically we are trying to use a microservice to send mail but the mailing procedures are all set up to be sent from the main server thread and maybe that's just thinking about it in the totally wrong way. is there another way to do this? |
I will check it. |
Thanks for you hard work!
P.S: I added some new tasks in the first comment. Could you do it? |
thanks for the responses! will follow up on the new tasks this weekend |
regarding "Disable to edit the "admin" user." - there may be more than one admin user. should one admin user be able to edit another admin user? |
please look at swyxio@4b96fff (here is the link to the ice-services branch itself) i have handled
i am having a lot of trouble with
i am not sure where is the best place to insert the error handling. i am currently trying to insert this in
and this would go into the user update flow (
I am not sure that this is a good way to do this as it doesnt do a "catchall" for all errors. |
Good question :) Please ignore this task :) I just want to block that admin can close out of page. E.g last admin remove |
No, no, the duplication is detected in MongoDB with schema. You only need to handle this exceptions and send back the error to the UI. Tomorrow I'll search example. |
yeah i had a feeling i was doing it very very wrong. |
No problem, just there is an easier way :) But thanks your diligent work :) |
So the apiKey is unique in Mongoose model. You do nothing with it. But if you try to save the same key, Mongoose will throw an exception. You have to handle it here |
i am facing serious trouble implementing this error handling. the problem is that the failure occurs further up the chain. for example if you try to create a user with a duplicate username, this happens on serverside:
I dont understand why the error code returned is 500 instead of 11000. but that is what is happening and so the clientside is not handling this correctly:
at the User.save function that you pointed to above. At this point i'm quite lost in the microservices as I cannot pinpoint where the error code is coming from. I think its coming because |
I think, you need to handle the error in return user.save().catch(err => {
if (err && err.code === 11000) {
let field = err.message.split(".$")[1];
field = field.split(" dup key")[0];
field = field.substring(0, field.lastIndexOf("_"));
let newErr = new Error("Unable to save user!");
newErr.params = {
field: field
};
newErr.status = 400;
throw newErr;
}
throw err;
}); Now it is catch the
|
this was my first-ever contribution to open source so thanks very much for patiently working with me on this :) I am going to work on a couple other projects and improve my skills for now but i will definitely keep an eye out for moleculer and when you roll out ice-services to the master branch!! |
Branch: ice-services
Server-side tasks:
server/services/applogic/users
). Recommend to clone thedevices
service. The Mongoose model is exist inserver/models/user.js
, just add a link file (like inpersons/models/user.js
)permission
isC.PERM_ADMIN
Client-side tasks:
client/app/modules/users
). Recommend to clone thedevices
service.DefaultAdminPage
fullName
,username
,email
,roles
,verified
,apiKey
,status
)core/router.js
&core/components/sidebar
New tasks:
The text was updated successfully, but these errors were encountered: