2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								package  api  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  (  
						 
					
						
							
								
									
										
										
										
											2021-10-04 21:46:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"context" 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-19 20:34:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"errors" 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"net/http" 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 00:55:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"strconv" 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-19 20:34:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 20:49:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/api/dtos" 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/api/response" 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/models" 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 16:21:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/login" 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 20:50:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/services/user" 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-10 01:27:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/setting" 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-19 23:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/util" 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/grafana/grafana/pkg/web" 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route GET /user signed_in_user getSignedInUser
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Get (current authenticated user)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: userResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 404: notFoundError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-05 16:59:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  GetSignedInUser ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  hs . getUserUserProfile ( c ,  c . UserID ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-18 23:28:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route GET /users/{user_id} users getUserByID
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Get user by id.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: userResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 404: notFoundError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-05 16:59:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  GetUserByID ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-01-15 00:55:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									id ,  err  :=  strconv . ParseInt ( web . Params ( c . Req ) [ ":id" ] ,  10 ,  64 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "id is invalid" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  hs . getUserUserProfile ( c ,  id ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-18 23:28:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-05 16:59:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  getUserUserProfile ( c  * models . ReqContext ,  userID  int64 )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									query  :=  models . GetUserProfileQuery { UserId :  userID } 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . SQLStore . GetUserProfile ( c . Req . Context ( ) ,  & query ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 20:50:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  errors . Is ( err ,  user . ErrUserNotFound )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  response . Error ( 404 ,  user . ErrUserNotFound . Error ( ) ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-31 13:25:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to get user" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									getAuthQuery  :=  models . GetAuthInfoQuery { UserId :  userID } 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-10 17:06:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									query . Result . AuthLabels  =  [ ] string { } 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . authInfoService . GetAuthInfo ( c . Req . Context ( ) ,  & getAuthQuery ) ;  err  ==  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 16:21:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										authLabel  :=  login . GetAuthProviderLabel ( getAuthQuery . Result . AuthModule ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-10 17:06:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										query . Result . AuthLabels  =  append ( query . Result . AuthLabels ,  authLabel ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										query . Result . IsExternal  =  true 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-25 23:29:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									query . Result . AccessControl  =  hs . getAccessControlMetadata ( c ,  c . OrgID ,  "global.users:id:" ,  strconv . FormatInt ( userID ,  10 ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-14 00:10:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									query . Result . AvatarUrl  =  dtos . GetGravatarUrl ( query . Result . Email ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-15 20:01:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  response . JSON ( http . StatusOK ,  query . Result ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route GET /users/lookup users getUserByLoginOrEmail
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Get user by login or email.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: userResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 404: notFoundError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  GetUserByLoginOrEmail ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-08-04 19:22:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									query  :=  user . GetUserByLoginQuery { LoginOrEmail :  c . Query ( "loginOrEmail" ) } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									usr ,  err  :=  hs . userService . GetByLogin ( c . Req . Context ( ) ,  & query ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 20:50:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  errors . Is ( err ,  user . ErrUserNotFound )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  response . Error ( 404 ,  user . ErrUserNotFound . Error ( ) ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-31 13:25:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to get user" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-31 13:25:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									result  :=  models . UserProfileDTO { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-04 19:22:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Id :              usr . ID , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Name :            usr . Name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Email :           usr . Email , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Login :           usr . Login , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Theme :           usr . Theme , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										IsGrafanaAdmin :  usr . IsAdmin , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										OrgId :           usr . OrgID , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										UpdatedAt :       usr . Updated , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CreatedAt :       usr . Created , 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-31 13:25:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-15 20:01:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  response . JSON ( http . StatusOK ,  & result ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-31 13:25:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route PUT /user signed_in_user updateSignedInUser
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Update signed in User.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: okResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  UpdateSignedInUser ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-08-04 20:22:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd  :=  user . UpdateUserCommand { } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  web . Bind ( c . Req ,  & cmd ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "bad request data" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-15 05:19:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  setting . AuthProxyEnabled  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  setting . AuthProxyHeaderProperty  ==  "email"  &&  cmd . Email  !=  c . Email  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  response . Error ( 400 ,  "Not allowed to change email when auth proxy is using email property" ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-15 05:19:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  setting . AuthProxyHeaderProperty  ==  "username"  &&  cmd . Login  !=  c . Login  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  response . Error ( 400 ,  "Not allowed to change username when auth proxy is using username property" ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-15 05:19:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd . UserID  =  c . UserID 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  hs . handleUpdateUser ( c . Req . Context ( ) ,  cmd ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 01:06:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route PUT /users/{user_id} users updateUser
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Update user.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Update the user identified by id.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: okResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 404: notFoundError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  UpdateUser ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-08-04 20:22:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd  :=  user . UpdateUserCommand { } 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 00:55:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									var  err  error 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  web . Bind ( c . Req ,  & cmd ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "bad request data" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-04 20:22:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd . UserID ,  err  =  strconv . ParseInt ( web . Params ( c . Req ) [ ":id" ] ,  10 ,  64 ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-15 00:55:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "id is invalid" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  hs . handleUpdateUser ( c . Req . Context ( ) ,  cmd ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 01:06:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-22 22:22:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// POST /api/users/:id/using/:orgId
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  UpdateUserActiveOrg ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-01-15 00:55:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									userID ,  err  :=  strconv . ParseInt ( web . Params ( c . Req ) [ ":id" ] ,  10 ,  64 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "id is invalid" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									orgID ,  err  :=  strconv . ParseInt ( web . Params ( c . Req ) [ ":orgId" ] ,  10 ,  64 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "orgId is invalid" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-26 12:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ! hs . validateUsingOrg ( c . Req . Context ( ) ,  userID ,  orgID )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 401 ,  "Not a valid organization" ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-26 12:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd  :=  models . SetUsingOrgCommand { UserId :  userID ,  OrgId :  orgID } 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-26 12:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . SQLStore . SetUsingOrg ( c . Req . Context ( ) ,  & cmd ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to change active organization" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-26 12:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  response . Success ( "Active organization changed" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-26 12:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-04 20:22:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  handleUpdateUser ( ctx  context . Context ,  cmd  user . UpdateUserCommand )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2015-05-19 01:06:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  len ( cmd . Login )  ==  0  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										cmd . Login  =  cmd . Email 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  len ( cmd . Login )  ==  0  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-24 22:59:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  response . Error ( http . StatusBadRequest ,  "Validation error, need to specify either username or email" ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 01:06:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-04 20:22:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . userService . Update ( ctx ,  & cmd ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 20:50:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  errors . Is ( err ,  user . ErrCaseInsensitive )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-24 22:59:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  response . Error ( http . StatusConflict ,  "Update would result in user login conflict" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusInternalServerError ,  "Failed to update user" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  response . Success ( "User updated" ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route GET /user/orgs signed_in_user getSignedInUserOrgList
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Organizations of the actual User.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Return a list of all organizations of the current user.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Security:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// - basic:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: getSignedInUserOrgListResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  GetSignedInUserOrgList ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  hs . getUserOrgList ( c . Req . Context ( ) ,  c . UserID ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-18 23:28:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route GET /user/teams signed_in_user getSignedInUserTeamList
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Teams that the actual User is member of.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Return a list of all teams that the current user is member of.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: getSignedInUserTeamListResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  GetSignedInUserTeamList ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  hs . getUserTeamList ( c ,  c . OrgID ,  c . UserID ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-19 17:08:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route GET /users/{user_id}/teams users getUserTeams
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Get teams for user.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Get teams for user identified by id.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: getUserTeamsResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 404: notFoundError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  GetUserTeams ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-01-15 00:55:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									id ,  err  :=  strconv . ParseInt ( web . Params ( c . Req ) [ ":id" ] ,  10 ,  64 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "id is invalid" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  hs . getUserTeamList ( c ,  c . OrgID ,  id ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-19 17:08:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 20:14:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  getUserTeamList ( c  * models . ReqContext ,  orgID  int64 ,  userID  int64 )  response . Response  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									query  :=  models . GetTeamsByUserQuery { OrgId :  orgID ,  UserId :  userID ,  SignedInUser :  c . SignedInUser } 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-08 16:26:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 20:14:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . SQLStore . GetTeamsByUser ( c . Req . Context ( ) ,  & query ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to get user teams" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-08 16:26:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  _ ,  team  :=  range  query . Result  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										team . AvatarUrl  =  dtos . GetGravatarUrlWithDefault ( team . Email ,  team . Name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-15 20:01:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  response . JSON ( http . StatusOK ,  query . Result ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-08 16:26:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route GET /users/{user_id}/orgs users getUserOrgList
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Get organizations for user.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Get organizations for user identified by id.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: getUserOrgListResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 404: notFoundError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  GetUserOrgList ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-01-15 00:55:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									id ,  err  :=  strconv . ParseInt ( web . Params ( c . Req ) [ ":id" ] ,  10 ,  64 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "id is invalid" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  hs . getUserOrgList ( c . Req . Context ( ) ,  id ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-18 23:28:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  getUserOrgList ( ctx  context . Context ,  userID  int64 )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									query  :=  models . GetUserOrgListQuery { UserId :  userID } 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-18 23:28:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . SQLStore . GetUserOrgList ( ctx ,  & query ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to get user organizations" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-15 20:01:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  response . JSON ( http . StatusOK ,  query . Result ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  validateUsingOrg ( ctx  context . Context ,  userID  int64 ,  orgID  int64 )  bool  {  
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									query  :=  models . GetUserOrgListQuery { UserId :  userID } 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . SQLStore . GetUserOrgList ( ctx ,  & query ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-24 03:07:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// validate that the org id in the list
 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									valid  :=  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  _ ,  other  :=  range  query . Result  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-22 19:37:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  other . OrgId  ==  orgID  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											valid  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  valid 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route POST /user/using/{org_id} signed_in_user userSetUsingOrg
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Switch user context for signed in user.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Switch user context to the given organization.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: okResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 400: badRequestError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  UserSetUsingOrg ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-01-15 00:55:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									orgID ,  err  :=  strconv . ParseInt ( web . Params ( c . Req ) [ ":id" ] ,  10 ,  64 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "id is invalid" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ! hs . validateUsingOrg ( c . Req . Context ( ) ,  c . UserID ,  orgID )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 401 ,  "Not a valid organization" ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd  :=  models . SetUsingOrgCommand { UserId :  c . UserID ,  OrgId :  orgID } 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . SQLStore . SetUsingOrg ( c . Req . Context ( ) ,  & cmd ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to change active organization" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  response . Success ( "Active organization changed" ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-20 01:01:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-02-19 23:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-10 01:27:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// GET /profile/switch-org/:id
  
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  ChangeActiveOrgAndRedirectToHome ( c  * models . ReqContext )  {  
						 
					
						
							
								
									
										
										
										
											2022-01-15 00:55:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									orgID ,  err  :=  strconv . ParseInt ( web . Params ( c . Req ) [ ":id" ] ,  10 ,  64 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										c . JsonApiErr ( http . StatusBadRequest ,  "id is invalid" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-10 01:27:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ! hs . validateUsingOrg ( c . Req . Context ( ) ,  c . UserID ,  orgID )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 17:26:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										hs . NotFoundHandler ( c ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-10 01:27:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd  :=  models . SetUsingOrgCommand { UserId :  c . UserID ,  OrgId :  orgID } 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-10 01:27:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . SQLStore . SetUsingOrg ( c . Req . Context ( ) ,  & cmd ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-12 17:26:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										hs . NotFoundHandler ( c ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-10 01:27:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-10 19:41:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									c . Redirect ( hs . Cfg . AppSubURL  +  "/" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-10 01:27:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route PUT /user/password signed_in_user changeUserPassword
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Change Password.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Changes the password for the user.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Security:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// - basic:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: okResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 400: badRequestError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  ChangeUserPassword ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-08-04 21:05:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd  :=  user . ChangeUserPasswordCommand { } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-29 17:18:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  web . Bind ( c . Req ,  & cmd ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "bad request data" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-15 05:19:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									userQuery  :=  user . GetUserByIDQuery { ID :  c . UserID } 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-19 23:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-02 22:58:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									user ,  err  :=  hs . userService . GetByID ( c . Req . Context ( ) ,  & userQuery ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Could not read user from database" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-19 23:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-08 13:12:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									getAuthQuery  :=  models . GetAuthInfoQuery { UserId :  user . ID } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  :=  hs . authInfoService . GetAuthInfo ( c . Req . Context ( ) ,  & getAuthQuery ) ;  err  ==  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										authModule  :=  getAuthQuery . Result . AuthModule 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 16:21:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  authModule  ==  login . LDAPAuthModule  ||  authModule  ==  login . AuthProxyAuthModule  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-08 13:12:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  response . Error ( 400 ,  "Not allowed to reset password for LDAP or Auth Proxy user" ,  nil ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-02 22:58:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									passwordHashed ,  err  :=  util . EncodePassword ( cmd . OldPassword ,  user . Salt ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-23 16:40:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to encode password" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-23 16:40:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-02 22:58:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  passwordHashed  !=  user . Password  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 401 ,  "Invalid old password" ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-19 23:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									password  :=  models . Password ( cmd . NewPassword ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-09 22:25:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  password . IsWeak ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 400 ,  "New password is too short" ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-19 23:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd . UserID  =  c . UserID 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-02 22:58:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd . NewPassword ,  err  =  util . EncodePassword ( cmd . NewPassword ,  user . Salt ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-23 16:40:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to encode password" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-23 16:40:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-19 23:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-04 21:05:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . userService . ChangePassword ( c . Req . Context ( ) ,  & cmd ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to change user password" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-19 23:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  response . Success ( "User password changed" ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-19 23:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-05-19 17:47:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-11 06:36:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// redirectToChangePassword handles GET /.well-known/change-password.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  redirectToChangePassword ( c  * models . ReqContext )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									c . Redirect ( "/profile/password" ,  302 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route PUT /user/helpflags/{flag_id} signed_in_user setHelpFlag
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Set user help flag.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: helpFlagResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  SetHelpFlag ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2022-01-15 00:55:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									flag ,  err  :=  strconv . ParseInt ( web . Params ( c . Req ) [ ":id" ] ,  10 ,  64 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  response . Error ( http . StatusBadRequest ,  "id is invalid" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-09 17:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bitmask  :=  & c . HelpFlags1 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 17:56:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bitmask . AddFlag ( user . HelpFlags1 ( flag ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-09 17:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd  :=  models . SetUserHelpFlagCommand { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										UserId :      c . UserID , 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-09 17:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										HelpFlags1 :  * bitmask , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . SQLStore . SetUserHelpFlag ( c . Req . Context ( ) ,  & cmd ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to update help flag" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-09 17:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-15 20:01:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  response . JSON ( http . StatusOK ,  & util . DynMap { "message" :  "Help flag set" ,  "helpFlags1" :  cmd . HelpFlags1 } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-09 17:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:route GET /user/helpflags/clear signed_in_user clearHelpFlags
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Clear user help flag.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Responses:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 200: helpFlagResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 401: unauthorisedError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 403: forbiddenError
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// 500: internalServerError
  
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  ( hs  * HTTPServer )  ClearHelpFlags ( c  * models . ReqContext )  response . Response  {  
						 
					
						
							
								
									
										
										
										
											2020-03-04 19:57:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cmd  :=  models . SetUserHelpFlagCommand { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-11 19:28:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										UserId :      c . UserID , 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-10 17:56:48 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										HelpFlags1 :  user . HelpFlags1 ( 0 ) , 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-09 17:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-27 03:24:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  hs . SQLStore . SetUserHelpFlag ( c . Req . Context ( ) ,  & cmd ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 21:43:20 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  response . Error ( 500 ,  "Failed to update help flag" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-09 17:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-15 20:01:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  response . JSON ( http . StatusOK ,  & util . DynMap { "message" :  "Help flag set" ,  "helpFlags1" :  cmd . HelpFlags1 } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-09 17:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2019-07-10 17:06:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 21:54:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// swagger:parameters searchUsers
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  SearchUsersParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Limit the maximum number of users to return per page
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:query
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:false
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// default:1000
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Limit  int64  ` json:"perpage" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Page index for starting fetching users
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:query
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:false
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// default:1
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Page  int64  ` json:"page" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:parameters searchUsersWithPaging
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  SearchUsersWithPagingParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Limit the maximum number of users to return per page
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:query
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:false
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// default:1000
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Limit  int64  ` json:"perpage" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Page index for starting fetching users
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:query
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:false
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// default:1
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Page  int64  ` json:"page" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Query allows return results where the query value is contained in one of the name, login or email fields. Query values with spaces need to be URL encoded e.g. query=Jane%20Doe
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:query
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:false
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Query  string  ` json:"query" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:parameters updateSignedInUser
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  UpdateSignedInUserParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// To change the email, name, login, theme, provide another one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Body  models . UpdateUserCommand  ` json:"body" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:parameters userSetUsingOrg
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  UserSetUsingOrgParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:path
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									OrgID  int64  ` json:"org_id" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:parameters setHelpFlag
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  SetHelpFlagParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:path
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									FlagID  string  ` json:"flag_id" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:parameters changeUserPassword
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  ChangeUserPasswordParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// To change the email, name, login, theme, provide another one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Body  models . ChangeUserPasswordCommand  ` json:"body" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:parameters getUserByID
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  GetUserByIDParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:path
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									UserID  int64  ` json:"user_id" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:parameters getUserOrgList
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  GetUserOrgListParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:path
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									UserID  int64  ` json:"user_id" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:parameters getUserTeams
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  GetUserTeamsParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:path
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									UserID  int64  ` json:"user_id" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:parameters getUserByLoginOrEmail
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  GetUserByLoginOrEmailParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// loginOrEmail of the user
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:query
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									LoginOrEmail  string  ` json:"loginOrEmail" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:parameters updateUser
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  UpdateUserParams  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// To change the email, name, login, theme, provide another one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Body  models . UpdateUserCommand  ` json:"body" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in:path
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// required:true
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									UserID  int64  ` json:"user_id" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:response searchUsersResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  SearchUsersResponse  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// The response message
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in: body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Body  models . SearchUserQueryResult  ` json:"body" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:response userResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  UserResponse  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// The response message
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in: body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Body  models . UserProfileDTO  ` json:"body" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:response getUserOrgListResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  GetUserOrgListResponse  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// The response message
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in: body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Body  [ ] * models . UserOrgDTO  ` json:"body" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:response getSignedInUserOrgListResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  GetSignedInUserOrgListResponse  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// The response message
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in: body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Body  [ ] * models . UserOrgDTO  ` json:"body" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:response getUserTeamsResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  GetUserTeamsResponse  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// The response message
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in: body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Body  [ ] * models . TeamDTO  ` json:"body" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:response getSignedInUserTeamListResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  GetSignedInUserTeamListResponse  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// The response message
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in: body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Body  [ ] * models . TeamDTO  ` json:"body" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// swagger:response helpFlagResponse
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								type  HelpFlagResponse  struct  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// The response message
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// in: body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Body  struct  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										HelpFlags1  int64   ` json:"helpFlags1" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Message     string  ` json:"message" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  ` json:"body" ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}