Use the correct api resource to accept invitations
parent
aee1ba35c8
commit
5304406226
|
@ -81,12 +81,13 @@ class AuthService extends taiga.Service
|
||||||
@.setUser(user)
|
@.setUser(user)
|
||||||
return user
|
return user
|
||||||
|
|
||||||
register: (data, type) ->
|
register: (data, type, existing) ->
|
||||||
url = @urls.resolve("auth-register")
|
url = @urls.resolve("auth-register")
|
||||||
|
|
||||||
data = _.clone(data, false)
|
data = _.clone(data, false)
|
||||||
data.type = if type then type else "public"
|
data.type = if type then type else "public"
|
||||||
data.existing = false
|
if type == "private"
|
||||||
|
data.existing = if existing then existing else false
|
||||||
|
|
||||||
return @http.post(url, data).then (response) =>
|
return @http.post(url, data).then (response) =>
|
||||||
user = @model.make_model("users", response.data)
|
user = @model.make_model("users", response.data)
|
||||||
|
@ -94,6 +95,12 @@ class AuthService extends taiga.Service
|
||||||
@.setUser(user)
|
@.setUser(user)
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
acceptInvitiationWithNewUser: (data) ->
|
||||||
|
return register(data, "private", false)
|
||||||
|
|
||||||
|
acceptInvitiationWithExistingUser: (data) ->
|
||||||
|
return register(data, "private", true)
|
||||||
|
|
||||||
forgotPassword: (data) ->
|
forgotPassword: (data) ->
|
||||||
url = @urls.resolve("users-password-recovery")
|
url = @urls.resolve("users-password-recovery")
|
||||||
|
|
||||||
|
@ -112,34 +119,6 @@ class AuthService extends taiga.Service
|
||||||
getInvitation: (token) ->
|
getInvitation: (token) ->
|
||||||
return @rs.invitations.get(token)
|
return @rs.invitations.get(token)
|
||||||
|
|
||||||
# acceptInvitiationWithNewUser: (username, email, password, token) ->
|
|
||||||
# url = @urls.resolve("auth-register")
|
|
||||||
# data = _.extend(data, {
|
|
||||||
# username: username,
|
|
||||||
# password: password,
|
|
||||||
# token: token
|
|
||||||
# email: email
|
|
||||||
# existing: "off"
|
|
||||||
# }
|
|
||||||
# return @http.post(url, data).then (response) =>
|
|
||||||
# user = @model.make_model("users", response.data)
|
|
||||||
# @.setToken(user.auth_token)
|
|
||||||
# @.setUser(user)
|
|
||||||
# return user
|
|
||||||
|
|
||||||
# acceptInvitiationWithExistingUser: (username, password, token) ->
|
|
||||||
# url = @urls.resolve("auth-register")
|
|
||||||
# data = _.extend(data, {
|
|
||||||
# username: username,
|
|
||||||
# password: password,
|
|
||||||
# token: token,
|
|
||||||
# existing: "on"
|
|
||||||
# }
|
|
||||||
# return @http.post(url, data).then (response) =>
|
|
||||||
# user = @model.make_model("users", response.data)
|
|
||||||
# @.setToken(user.auth_token)
|
|
||||||
# @.setUser(user)
|
|
||||||
# return user
|
|
||||||
|
|
||||||
module.service("$tgAuth", AuthService)
|
module.service("$tgAuth", AuthService)
|
||||||
|
|
||||||
|
@ -204,7 +183,6 @@ RegisterDirective = ($auth, $confirm) ->
|
||||||
$location.path("/project/project-example-0/backlog")
|
$location.path("/project/project-example-0/backlog")
|
||||||
|
|
||||||
promise.then null, (response) ->
|
promise.then null, (response) ->
|
||||||
if response.data._error_message
|
|
||||||
$confirm.notify("light-error", "According to our Oompa Loompas,
|
$confirm.notify("light-error", "According to our Oompa Loompas,
|
||||||
your are not registered yet or
|
your are not registered yet or
|
||||||
type an invalid password.") #TODO: i18n
|
type an invalid password.") #TODO: i18n
|
||||||
|
@ -242,7 +220,6 @@ ForgotPasswordDirective = ($auth, $confirm, $location) ->
|
||||||
with the instructions to set a new password") #TODO: i18n
|
with the instructions to set a new password") #TODO: i18n
|
||||||
|
|
||||||
promise.then null, (response) ->
|
promise.then null, (response) ->
|
||||||
if response.data._error_message
|
|
||||||
$confirm.notify("light-error", "According to our Oompa Loompas,
|
$confirm.notify("light-error", "According to our Oompa Loompas,
|
||||||
your are not registered yet.") #TODO: i18n
|
your are not registered yet.") #TODO: i18n
|
||||||
|
|
||||||
|
@ -284,7 +261,6 @@ ChangePasswordFromRecoveryDirective = ($auth, $confirm, $location, $params) ->
|
||||||
Try to <strong>sign in</strong> with it.") #TODO: i18n
|
Try to <strong>sign in</strong> with it.") #TODO: i18n
|
||||||
|
|
||||||
promise.then null, (response) ->
|
promise.then null, (response) ->
|
||||||
if response.data._error_message
|
|
||||||
$confirm.notify("light-error", "One of our Oompa Loompas say
|
$confirm.notify("light-error", "One of our Oompa Loompas say
|
||||||
'#{response.data._error_message}'.") #TODO: i18n
|
'#{response.data._error_message}'.") #TODO: i18n
|
||||||
|
|
||||||
|
@ -326,7 +302,7 @@ InvitationDirective = ($auth, $confirm, $location, $params) ->
|
||||||
if not loginForm.validate()
|
if not loginForm.validate()
|
||||||
return
|
return
|
||||||
|
|
||||||
promise = $auth.login($scope.dataLogin)
|
promise = $auth.acceptInvitiationWithExistingUser($scope.dataLogin)
|
||||||
promise.then (response) ->
|
promise.then (response) ->
|
||||||
# TODO: finish this. Go tu project home page
|
# TODO: finish this. Go tu project home page
|
||||||
$location.path("/project/#{$scope.invitation.project_slug}/backlog")
|
$location.path("/project/#{$scope.invitation.project_slug}/backlog")
|
||||||
|
@ -357,7 +333,7 @@ InvitationDirective = ($auth, $confirm, $location, $params) ->
|
||||||
if not registerForm.validate()
|
if not registerForm.validate()
|
||||||
return
|
return
|
||||||
|
|
||||||
promise = $auth.register($scope.dataRegister, "private")
|
promise = $auth.acceptInvitiationWithNewUser($scope.dataRegister)
|
||||||
promise.then (response) ->
|
promise.then (response) ->
|
||||||
# TODO: finish this. Go tu project home page
|
# TODO: finish this. Go tu project home page
|
||||||
$location.path("/project/#{$scope.invitation.project_slug}/backlog")
|
$location.path("/project/#{$scope.invitation.project_slug}/backlog")
|
||||||
|
@ -365,7 +341,6 @@ InvitationDirective = ($auth, $confirm, $location, $params) ->
|
||||||
"Wellcome to #{$scope.invitation.project_name}")
|
"Wellcome to #{$scope.invitation.project_name}")
|
||||||
|
|
||||||
promise.then null, (response) ->
|
promise.then null, (response) ->
|
||||||
if response.data._error_message
|
|
||||||
$confirm.notify("light-error", "According to our Oompa Loompas,
|
$confirm.notify("light-error", "According to our Oompa Loompas,
|
||||||
your username/email or password
|
your username/email or password
|
||||||
are incorrect.") #TODO: i18n
|
are incorrect.") #TODO: i18n
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//- To Aadd a new notification type:
|
//- To Aadd a new notification type:
|
||||||
//-
|
//-
|
||||||
//- div.hidden.notification-message.notification-message-< type >
|
//- div.notification-message.notification-message-< type >
|
||||||
//- (...)
|
//- (...)
|
||||||
//- h4 < title >
|
//- h4 < title >
|
||||||
//- (...)
|
//- (...)
|
||||||
|
|
Loading…
Reference in New Issue