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
Container registry
Model registry
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
Maunium
synapse
Commits
e36b18ad
Commit
e36b18ad
authored
10 years ago
by
Kegan Dougal
Browse files
Options
Downloads
Patches
Plain Diff
Get everything working
parent
e6363857
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
static/client/register/index.html
+5
-9
5 additions, 9 deletions
static/client/register/index.html
static/client/register/js/register.js
+108
-15
108 additions, 15 deletions
static/client/register/js/register.js
with
113 additions
and
24 deletions
static/client/register/index.html
+
5
−
9
View file @
e36b18ad
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
<head>
<head>
<title>
Registration
</title>
<title>
Registration
</title>
<link
rel=
"stylesheet"
href=
"style.css"
>
<link
rel=
"stylesheet"
href=
"style.css"
>
<script
src=
"js/jquery-2.1.3.min.js"
></script>
<script
src=
"js/recaptcha_ajax.js"
></script>
<script
src=
"js/recaptcha_ajax.js"
></script>
<script
src=
"register_config.js"
></script>
<script
src=
"register_config.js"
></script>
<script
src=
"js/register.js"
></script>
<script
src=
"js/register.js"
></script>
...
@@ -18,16 +19,11 @@
...
@@ -18,16 +19,11 @@
<br/>
<br/>
<input
id=
"pwd2"
size=
"32"
type=
"password"
placeholder=
"Confirm your password"
/>
<input
id=
"pwd2"
size=
"32"
type=
"password"
placeholder=
"Confirm your password"
/>
<br/>
<br/>
<span
id=
"feedback"
style=
"color: #f00"
></span>
<br/>
<div
id=
"regcaptcha"
></div>
<div
id=
"regcaptcha"
/>
<button
type=
"button"
style=
"margin: 10px"
onclick=
"matrixRegistration.signUp()"
>
Sign up
</button>
<button
style=
"margin: 10px"
>
Sign up
</button>
</div>
<div
id=
"serverConfig"
ng-show=
"!wait_3pid_code"
>
<label
for=
"homeserver"
>
Home Server:
</label>
<input
id=
"homeserver"
size=
"32"
type=
"text"
placeholder=
"URL (e.g. http://matrix.org:8080)"
/>
<div
class=
"smallPrint"
>
Your home server stores all your conversation and account data.
</div>
</div>
</div>
</div>
</div>
</form>
</form>
...
...
This diff is collapsed.
Click to expand it.
static/client/register/js/register.js
+
108
−
15
View file @
e36b18ad
window
.
matrixRegistration
=
{};
window
.
matrixRegistration
=
{
endpoint
:
location
.
origin
+
"
/_matrix/client/api/v1/register
"
};
var
setupCaptcha
=
function
()
{
var
setupCaptcha
=
function
()
{
if
(
!
window
.
matrixRegistrationConfig
)
{
if
(
!
window
.
matrixRegistrationConfig
)
{
return
;
}
console
.
log
(
"
Setting up ReCaptcha
"
);
var
public_key
=
window
.
matrixRegistrationConfig
.
recaptcha_public_key
;
if
(
public_key
===
undefined
)
{
console
.
error
(
"
No public key defined for captcha!
"
);
return
;
return
;
}
}
Recaptcha
.
create
(
public_key
,
$
.
get
(
matrixRegistration
.
endpoint
,
function
(
response
)
{
"
regcaptcha
"
,
var
serverExpectsCaptcha
=
false
;
{
for
(
var
i
=
0
;
i
<
response
.
flows
.
length
;
i
++
)
{
theme
:
"
red
"
,
var
flow
=
response
.
flows
[
i
];
callback
:
Recaptcha
.
focus_response_field
if
(
"
m.login.recaptcha
"
===
flow
.
type
)
{
serverExpectsCaptcha
=
true
;
break
;
}
}
if
(
!
serverExpectsCaptcha
)
{
console
.
log
(
"
This server does not require a captcha.
"
);
return
;
}
console
.
log
(
"
Setting up ReCaptcha for
"
+
matrixRegistration
.
endpoint
);
var
public_key
=
window
.
matrixRegistrationConfig
.
recaptcha_public_key
;
if
(
public_key
===
undefined
)
{
console
.
error
(
"
No public key defined for captcha!
"
);
return
;
}
Recaptcha
.
create
(
public_key
,
"
regcaptcha
"
,
{
theme
:
"
red
"
,
callback
:
Recaptcha
.
focus_response_field
});
window
.
matrixRegistration
.
isUsingRecaptcha
=
true
;
}).
error
(
errorFunc
);
};
var
submitCaptcha
=
function
(
user
,
pwd
)
{
var
challengeToken
=
Recaptcha
.
get_challenge
();
var
captchaEntry
=
Recaptcha
.
get_response
();
var
data
=
{
type
:
"
m.login.recaptcha
"
,
challenge
:
challengeToken
,
response
:
captchaEntry
};
console
.
log
(
"
Submitting captcha
"
);
$
.
post
(
matrixRegistration
.
endpoint
,
JSON
.
stringify
(
data
),
function
(
response
)
{
console
.
log
(
"
Success ->
"
+
JSON
.
stringify
(
response
));
submitPassword
(
user
,
pwd
,
response
.
session
);
}).
error
(
function
(
err
)
{
Recaptcha
.
reload
();
errorFunc
(
err
);
});
});
};
};
var
submitPassword
=
function
(
user
,
pwd
,
session
)
{
console
.
log
(
"
Registering...
"
);
var
data
=
{
type
:
"
m.login.password
"
,
user
:
user
,
password
:
pwd
,
session
:
session
};
$
.
post
(
matrixRegistration
.
endpoint
,
JSON
.
stringify
(
data
),
function
(
response
)
{
matrixRegistration
.
onRegistered
(
response
.
home_server
,
response
.
user_id
,
response
.
access_token
);
}).
error
(
errorFunc
);
};
var
errorFunc
=
function
(
err
)
{
if
(
err
.
responseJSON
&&
err
.
responseJSON
.
error
)
{
setFeedbackString
(
err
.
responseJSON
.
error
+
"
(
"
+
err
.
responseJSON
.
errcode
+
"
)
"
);
}
else
{
setFeedbackString
(
"
Request failed:
"
+
err
.
status
);
}
};
var
setFeedbackString
=
function
(
text
)
{
$
(
"
#feedback
"
).
text
(
text
);
};
matrixRegistration
.
onLoad
=
function
()
{
matrixRegistration
.
onLoad
=
function
()
{
setupCaptcha
();
setupCaptcha
();
};
};
\ No newline at end of file
matrixRegistration
.
signUp
=
function
()
{
var
user
=
$
(
"
#desired_user_id
"
).
val
();
if
(
user
.
length
==
0
)
{
setFeedbackString
(
"
Must specify a username.
"
);
return
;
}
var
pwd1
=
$
(
"
#pwd1
"
).
val
();
var
pwd2
=
$
(
"
#pwd2
"
).
val
();
if
(
pwd1
.
length
<
6
)
{
setFeedbackString
(
"
Password: min. 6 characters.
"
);
return
;
}
if
(
pwd1
!=
pwd2
)
{
setFeedbackString
(
"
Passwords do not match.
"
);
return
;
}
if
(
window
.
matrixRegistration
.
isUsingRecaptcha
)
{
submitCaptcha
(
user
,
pwd1
);
}
else
{
submitPassword
(
user
,
pwd1
);
}
};
matrixRegistration
.
onRegistered
=
function
(
hs_url
,
user_id
,
access_token
)
{
// clobber this function
console
.
log
(
"
onRegistered - This function should be replaced to proceed.
"
);
};
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