Comments (4)
Hey Nischal, the usage of reqparse looks fine to me, but we wouldn't want anyone to be able to send a DELETE request with arbitrary email addresses and have those user accounts deleted - so this should rather have an @auth_required attribute and use g.current_user['id'] to get the current user id :)
from baobab.
Will implement the backend part of this issue.
from baobab.
@jaderabbit - I am struggling a bit with resource, mixins and APIs. Would it be right If I did this here:
class UserAPI(SignupMixin, restful.Resource):
@auth_required
@marshal_with(user_fields)
def get(self):
user = db.session.query(AppUser).filter(AppUser.id==g.current_user['id']).first()
return user
def post(self):
args = self.req_parser.parse_args()
email = args['email']
firstname = args['firstname']
lastname = args['lastname']
user_title = args['user_title']
nationality_country_id = args['nationality_country_id']
residence_country_id = args['residence_country_id']
user_ethnicity = args['user_ethnicity']
user_gender = args['user_gender']
affiliation = args['affiliation']
department = args['department']
user_disability = args['user_disability']
user_category_id = args['user_category_id']
password = args['password']
user = AppUser(
email=email,
firstname=firstname,
lastname=lastname,
user_title=user_title,
nationality_country_id=nationality_country_id,
residence_country_id=residence_country_id,
user_ethnicity=user_ethnicity,
user_gender=user_gender,
affiliation=affiliation,
department=department,
user_disability=user_disability,
user_category_id=user_category_id,
password=password)
db.session.add(user)
try:
db.session.commit()
except IntegrityError:
return EMAIL_IN_USE
return {
'id': user.id,
'token': generate_token(user)
}, 201
def delete(self):
'''
The function that lets the user delete the account
'''
req_parser = reqparse.RequestParser()
req_parser.add_argument('email', type=str, required=True)
args = req_parser.parse_args()
user = db.session.query(AppUser).filter(AppUser.email==args['email']).first()
if user:
user.is_deleted = True
db.session.update(user)
db.session.commit()
return {}, 201
from baobab.
Okay that sounds great, will do those change and send across the PR right away. This issue needs to be closed, apologize for the delay from my end.
from baobab.
Related Issues (20)
- Remove dates for Continuous Journal Event Type HOT 1
- Use Profile Page
- Remove Dates for Continuous Journal
- Error when using Google Translate
- Journal Submission: Email Admin
- Add Review State to Review Assignment
- Offer and outcome management
- Update travel and acommodation grants to work with tags. HOT 3
- Add tag filters to review assignment
- Add Outcome to Response
- Add reviews to response page
- Send email when a flag is added to a user
- Add document upload functionality
- Depends on question... functionality doesn't seem to work HOT 1
- Event editor not working for extending application deadlines
- Assigning reviewers to individual applications (bug)
- General attendees who haven't registered and haven't paid can still be checked-in
- Form fields being reset to defaults on edit HOT 2
- Removal of Guests from the Invited Guest List HOT 1
- Getting internal server error when trying to view invoice
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from baobab.