Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
d821755b
"README.md" did not exist on "e3a49f4784d5c915355ac9306e60b09433db60b5"
Commit
d821755b
authored
10 years ago
by
Kegan Dougal
Browse files
Options
Downloads
Patches
Plain Diff
Updated webclient to support the new registration logic.
parent
285ecaac
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webclient/components/matrix/matrix-service.js
+120
-23
120 additions, 23 deletions
webclient/components/matrix/matrix-service.js
with
120 additions
and
23 deletions
webclient/components/matrix/matrix-service.js
+
120
−
23
View file @
d821755b
...
@@ -81,38 +81,135 @@ angular.module('matrixService', [])
...
@@ -81,38 +81,135 @@ angular.module('matrixService', [])
return
$http
(
request
);
return
$http
(
request
);
};
};
var
doRegisterLogin
=
function
(
path
,
loginType
,
sessionId
,
userName
,
password
,
threepidCreds
)
{
var
data
=
{};
if
(
loginType
===
"
m.login.recaptcha
"
)
{
var
challengeToken
=
Recaptcha
.
get_challenge
();
var
captchaEntry
=
Recaptcha
.
get_response
();
data
=
{
type
:
"
m.login.recaptcha
"
,
challenge
:
challengeToken
,
response
:
captchaEntry
};
}
else
if
(
loginType
===
"
m.login.email.identity
"
)
{
data
=
{
threepidCreds
:
threepidCreds
};
}
else
if
(
loginType
===
"
m.login.password
"
)
{
data
=
{
user_id
:
userName
,
password
:
password
};
}
if
(
sessionId
)
{
data
.
session
=
sessionId
;
}
data
.
type
=
loginType
;
console
.
log
(
"
doRegisterLogin >>>
"
+
loginType
);
return
doRequest
(
"
POST
"
,
path
,
undefined
,
data
);
};
return
{
return
{
/****** Home server API ******/
/****** Home server API ******/
prefix
:
prefixPath
,
prefix
:
prefixPath
,
// Register an user
// Register an user
register
:
function
(
user_name
,
password
,
threepidCreds
,
useCaptcha
)
{
register
:
function
(
user_name
,
password
,
threepidCreds
,
useCaptcha
)
{
// The REST path spec
// registration is composed of multiple requests, to check you can
// register, then to actually register. This deferred will fire when
// all the requests are done, along with the final response.
var
deferred
=
$q
.
defer
();
var
path
=
"
/register
"
;
var
path
=
"
/register
"
;
var
data
=
{
// check we can actually register with this HS.
user_id
:
user_name
,
doRequest
(
"
GET
"
,
path
,
undefined
,
undefined
).
then
(
password
:
password
,
function
(
response
)
{
threepidCreds
:
threepidCreds
console
.
log
(
"
/register [1] :
"
+
JSON
.
stringify
(
response
));
};
var
flows
=
response
.
data
.
flows
;
var
knownTypes
=
[
"
m.login.password
"
,
"
m.login.recaptcha
"
,
"
m.login.email.identity
"
];
// if they entered 3pid creds, we want to use a flow which uses it.
var
useThreePidFlow
=
threepidCreds
!=
undefined
;
var
flowIndex
=
0
;
var
firstRegType
=
undefined
;
for
(
var
i
=
0
;
i
<
flows
.
length
;
i
++
)
{
var
isThreePidFlow
=
false
;
if
(
flows
[
i
].
stages
)
{
for
(
var
j
=
0
;
j
<
flows
[
i
].
stages
.
length
;
j
++
)
{
var
regType
=
flows
[
i
].
stages
[
j
];
if
(
knownTypes
.
indexOf
(
regType
)
===
-
1
)
{
deferred
.
reject
(
"
Unknown type:
"
+
regType
);
return
;
}
if
(
regType
==
"
m.login.email.identity
"
)
{
isThreePidFlow
=
true
;
}
if
(
!
useCaptcha
&&
regType
==
"
m.login.recaptcha
"
)
{
console
.
error
(
"
Web client setup to not use captcha, but HS demands a captcha.
"
);
}
}
}
if
(
(
isThreePidFlow
&&
useThreePidFlow
)
||
(
!
isThreePidFlow
&&
!
useThreePidFlow
)
)
{
flowIndex
=
i
;
}
if
(
knownTypes
.
indexOf
(
flows
[
i
].
type
)
==
-
1
)
{
deferred
.
reject
(
"
Unknown type:
"
+
flows
[
i
].
type
);
return
;
}
}
// looks like we can register fine, go ahead and do it.
console
.
log
(
"
Using flow
"
+
JSON
.
stringify
(
flows
[
flowIndex
]));
firstRegType
=
flows
[
flowIndex
].
type
;
var
sessionId
=
undefined
;
// generic response processor so it can loop as many times as required
var
loginResponseFunc
=
function
(
response
)
{
if
(
response
.
data
.
session
)
{
sessionId
=
response
.
data
.
session
;
}
console
.
log
(
"
login response:
"
+
JSON
.
stringify
(
response
.
data
));
if
(
response
.
data
.
access_token
)
{
deferred
.
resolve
(
response
);
}
else
if
(
response
.
data
.
next
)
{
return
doRegisterLogin
(
path
,
response
.
data
.
next
,
sessionId
,
user_name
,
password
,
threepidCreds
).
then
(
loginResponseFunc
,
function
(
err
)
{
deferred
.
reject
(
err
);
}
);
}
else
{
deferred
.
reject
(
"
Unknown continuation:
"
+
JSON
.
stringify
(
response
));
}
};
// set the ball rolling
doRegisterLogin
(
path
,
firstRegType
,
undefined
,
user_name
,
password
,
threepidCreds
).
then
(
loginResponseFunc
,
function
(
err
)
{
deferred
.
reject
(
err
);
}
);
},
function
(
err
)
{
deferred
.
reject
(
err
);
}
);
if
(
useCaptcha
)
{
return
deferred
.
promise
;
// Not all home servers will require captcha on signup, but if this flag is checked,
// send captcha information.
// TODO: Might be nice to make this a bit more flexible..
var
challengeToken
=
Recaptcha
.
get_challenge
();
var
captchaEntry
=
Recaptcha
.
get_response
();
var
captchaType
=
"
m.login.recaptcha
"
;
data
.
captcha
=
{
type
:
captchaType
,
challenge
:
challengeToken
,
response
:
captchaEntry
};
}
return
doRequest
(
"
POST
"
,
path
,
undefined
,
data
);
},
},
// Create a room
// Create a room
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment