@@ -141,6 +141,64 @@ module.exports = {
141141 Controllers . Account . addUser
142142 ) ;
143143
144+ /**
145+ * @api {post } /account/invite invites a user to create an account with the specified accountType
146+ * @apiName inviteAccount
147+ * @apiGroup Account
148+ * @apiVersion 0.0.8
149+ * @apiDescription sends link with token to be used with the account/create route
150+ *
151+ * @apiParam (body) {String} [email] email of the account to be created and where to send the link
152+ * @apiParam (body) {String} [accountType] the type of the account which the user can create, for sponsor this should specify tier as well
153+ *
154+ * @apiSuccess {string} message Success message
155+ * @apiSuccess {object} data Account object
156+ * @apiSuccessExample {object} Success-Response:
157+ * {
158+ "message": "Successfully invited user",
159+ "data": {}
160+ }
161+ * @apiError {string} message Error message
162+ * @apiError {object} data Error object
163+ * @apiErrorExample {object} Error-Response:
164+ * {
165+ "message": "Invalid Authentication",
166+ "data": {
167+ "route": "/invite"
168+ }
169+ }
170+ */
171+ accountRouter . route ( "/invite" ) . post (
172+ Middleware . Auth . ensureAuthenticated ( ) ,
173+ Middleware . Auth . ensureAuthorized ( ) ,
174+ Middleware . Validator . Account . inviteAccountValidator ,
175+ Middleware . parseBody . middleware ,
176+ Middleware . Account . inviteAccount ,
177+ Controllers . Account . invitedAccount
178+ ) ;
179+ /**
180+ * @api {get } /account/invite Get all of the invites.
181+ * @apiName getAllInvites
182+ * @apiGroup Account
183+ * @apiVersion 0.0.8
184+ * @apiDescription Get all of the invites that currently exist in the database.
185+ * @apiSuccessExample {object} Success-Response:
186+ * {
187+ "message": "Invite retrieval successful.",
188+ "data": [{
189+ "email":"abc@def .com",
190+ "accountType":"Hacker"
191+ }]
192+ }
193+ */
194+ accountRouter . route ( "/invite" ) . get (
195+ Middleware . Auth . ensureAuthenticated ( ) ,
196+ Middleware . Auth . ensureAuthorized ( ) ,
197+ Middleware . parseBody . middleware ,
198+ Middleware . Account . getInvites ,
199+ Controllers . Account . gotInvites
200+ ) ;
201+
144202 /**
145203 * @api {patch } /account/:id update an account's information
146204 * @apiName updateOneUser
@@ -241,42 +299,6 @@ module.exports = {
241299 Controllers . Account . showAccount
242300 ) ;
243301
244- /**
245- * @api {post } /account/invite invites a user to create an account with the specified accountType
246- * @apiName inviteAccount
247- * @apiGroup Account
248- * @apiVersion 0.0.8
249- * @apiDescription sends link with token to be used with the account/create route
250- *
251- * @apiParam (body) {String} [email] email of the account to be created and where to send the link
252- * @apiParam (body) {String} [accountType] the type of the account which the user can create, for sponsor this should specify tier as well
253- *
254- * @apiSuccess {string} message Success message
255- * @apiSuccess {object} data Account object
256- * @apiSuccessExample {object} Success-Response:
257- * {
258- "message": "Successfully invited user",
259- "data": {}
260- }
261- * @apiError {string} message Error message
262- * @apiError {object} data Error object
263- * @apiErrorExample {object} Error-Response:
264- * {
265- "message": "Invalid Authentication",
266- "data": {
267- "route": "/invite"
268- }
269- }
270- */
271- accountRouter . route ( "/invite" ) . post (
272- Middleware . Auth . ensureAuthenticated ( ) ,
273- Middleware . Auth . ensureAuthorized ( ) ,
274- Middleware . Validator . Account . inviteAccountValidator ,
275- Middleware . parseBody . middleware ,
276- Middleware . Account . inviteAccount ,
277- Controllers . Account . invitedAccount
278- ) ;
279-
280302 apiRouter . use ( "/account" , accountRouter ) ;
281303 }
282304} ;
0 commit comments