how to assign admin functions to users - javascript

I have a site where every club member is free to register& login but cannot chat/or view other members profile without being confirmed by the admin. We are only 5 in admin level but people joining are too much for us.
My question is; I need a code which will enable any confirmed member to confirm two members.
Simply put: code to make 1 approve 2&3. 2 will approve 4&5.3 will approve 5&6. That means turn by turn work. A kind of 2:1 matrix. Anyone who have approved someone can't approve again. Thanks in advance.

When the user is approved he should be granted 2 approvals - as he can approve anyone you need to subtract the number of people he can approve after he does that. It would be pretty simple to do as you just need one extra column in the users table in the database.
As for the code that depends entirely on your application and you did not specify any details of it.

Related

How to make a currency shop using mongodb and discord.js

I'm trying to make a adventure discord bot I have programmed many commands and I have also created a currency and ways to make money but I don't have a way to spend the money except to pay so you don't get in prison. I want to make a store where you can buy items and other stuff. I haven't written any code for that because I have no idea of what to do and how to do it. If anyone knows please reply.
In your pay command, you clearly have a function that takes away some amount of money, right?
So you can just make a simple pagintated embed with discord pagination, or something like that, I forgot how to spell it, and then just list the pricing. That's your shop command.
Then make the buy command. You then check whats after the buy command, for example, I recommend adding something like IDS to the items in your shop, and the listing it near the item or in its description in the embed, and then when a user uses the buy command, check what ID is after it.
If there's simply nothing, or you didn't find the id in your args, then simply return an embed saying the item was not found, please use (prefix) shop command.
Then if the user does mention an item, then take away the amount of money from the database with that function from the pay command, and then just simply load the item into the users database inventory. :)

Dialogflow Basket Multiple order

I'm new here
I have one question but I can't put her correctly in right words, cause my English is bad, but I'm gonna try
I want to build a shopping basket in dialogflow, like this scheme:
first, the user selects a category (pizza for example) now the user select the pizza he wants (1 = margherita, for example) now I want to send him a message ''do you want to close the basket"? if the answer is ''no'' the bot back to the first line (select category) and the bot gonna add up the items and prices to basket if the answer is "yes'' the bot shows the basket with price ( 1 margherita for 5$)
sorry if you were confused. thanks.
Without revealing the answer, I'll point you in the correct direction.
Dialogflow handles multi-interaction conversations through something called contexts. Contexts allow you to save the state of a conversation through a specified life-cycle.
You might notice in your intent builder on the Dialogflow console, towards the top there is a place to set input and output contexts. Intents that receive input contexts will be triggered when an intent sets that same context as the output context.
This allows you to chain intents together to allow the back and forth of a normal conversation.
For more info on contexts Dialogflow has good documentation

How could I manage permissions of jhipster's authorities?

I am coding a webapp using JHipster code generator.
I created 2 extra roles, now I have 5 in total:
ROLE_USER, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_PRESIDENT, ROLE_VICE_PRESIDENT
I was wondering how could I manage their permissions to show some RESTs.
For example, I would like to let the PRESIDENT add new users to database, other simple users should not see the web service that do the work.
Is there a file that I'm ignoring by mistake that could help me with this feature?
Giving thanks in advice for your precious time,
Manuel
Adding new roles to JHipster needs to be added in 2 places.
The obvious one is the AngularJS frontend. To add your new role to user edit view, you add them to the select options in "user-management.controller.js" at vm.authorities = ['ROLE_USER', 'ROLE_ADMIN']
To enforce the role at different places in UI, you either add your roles to the state JS files. Just add them to data.authorities (check user-management.state.js)
If you like to have a template block visible only if a user has the proper role, check out the hasAnyAuthority directive.
The other Part is to secure the backend. If using a current JHipster version and SQL database, authorities are stored in the database. Add your custom roles to authorities.csv of your liquibase migrations.
Last but not least, you can enforce roles in WebSecurityConfiguration or MicroserviceSecurityConfiguration (just look at the existing antMatchers)

Password protection for a page with a simple function - what are the downsides?

I am doing work on an e-commerce platform, and I was asked to come up with a solution so that a certain group of customers could enter a password protected page on the site. The platform doesn't allow for this, as in the functionality is not available, so according to customer support, it's something you would have to create a custom template for and build from scratch. It doesn't need to be fancy, or hacker proof, just secure enough. So instead of doing that, I dropped the script below into the body of the page.
My first version: I use a prompt to ask for an input (password). If you click "prevent this page from creating additional dialouges", it creates sort of an infinite reload loop for that tab (not ideal, but problem?). Are there other serious problems? Easy hacks for your average person?
$("body").hide();
var passwordCheckFunction = function() {
var testPassword = window.prompt("YOU SHALL NOT PASS");
if (testPassword === "thisPredefinedPassword") {
$("body").show();
} else {
location.reload();
}
};
passwordCheckFunction();
Any advice would be much appreciated, and thank you for your time.
Create your secret page as a category.
Customize it to your heart's desire by choosing a custom template
file for it.
Finally, restrict it to only the authorized customer group
by removing it from view from guests and every group except the
authorized one.
Using this method, the customer only has to sign into his/her own customer account. BigCommerce will prevent access to the page by reading the assigned customer group of the customer.
I realize this isn't your desired method, but you might consider instead just making your page inactive in the admin area of your BC store, then instead of a password provide the direct url for users that are able to see that page.
I'm not sure about the implications for google indexing with an inactive page, but I would assume that they are set not to index it, and if not you could set it in robots.txt

Determine user type in Google Class Room (Either Teacher or Student)

How can I determine if a user that is logged into my app is a Teacher or a Student?
I can successfully log in to my app using a Google Classroom test account, but when I look at the information retrieved, I see nothing in regards to role. I've looked through the API but so far I've only seen calls related to getting courses and rosters. I tried the user profile call, but the info returned did not include a role.
At a basic level, I just want to do loggedInUser.role === teacher.
Edit:
Updated for clarification. I am not looking for courses.students or courses.teachers. I consider those roster information. I already have a profile from a logged in user. I shouldn't have to see what role they are by listing teachers in a course.
Via the Classroom API, you can only determine if a user is a teacher or a student relative to a particular course. (It's possible for a user to be a teacher in one course, and a student in another.)
If you need to determine if a user is a real-world teacher or student, you need to do this via a mechanism separate from Classroom.
You might also like to star this issue to learn about any possible improvements to the API.
You're looking for courses.students and courses.teachers:
https://developers.google.com/classroom/reference/rest/v1/courses.students
https://developers.google.com/classroom/reference/rest/v1/courses.teachers
Once you have a course ID you can query these using the "list" request:
https://developers.google.com/classroom/reference/rest/v1/courses.teachers/list
https://developers.google.com/classroom/reference/rest/v1/courses.students/list

Categories

Resources