mirror of https://github.com/writeas/writefreely
This adds any OAuth login buttons to the invite signup page, stores the invite code for the flow duration, and associates the new user with it once successfully registered. It enables invite-only instances with OAuth-based registration.pull/303/head
parent
93c2773412
commit
ca4a576c31
@ -0,0 +1,45 @@ |
|||||||
|
/* |
||||||
|
* Copyright © 2020 A Bunch Tell LLC. |
||||||
|
* |
||||||
|
* This file is part of WriteFreely. |
||||||
|
* |
||||||
|
* WriteFreely is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU Affero General Public License, included |
||||||
|
* in the LICENSE file in this source code package. |
||||||
|
*/ |
||||||
|
|
||||||
|
.row.signinbtns { |
||||||
|
justify-content: space-evenly; |
||||||
|
font-size: 1em; |
||||||
|
margin-top: 3em; |
||||||
|
margin-bottom: 2em; |
||||||
|
|
||||||
|
.loginbtn { |
||||||
|
height: 40px; |
||||||
|
} |
||||||
|
|
||||||
|
#writeas-login, #gitlab-login { |
||||||
|
box-sizing: border-box; |
||||||
|
font-size: 17px; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
.or { |
||||||
|
text-align: center; |
||||||
|
margin-bottom: 3.5em; |
||||||
|
|
||||||
|
p { |
||||||
|
display: inline-block; |
||||||
|
background-color: white; |
||||||
|
padding: 0 1em; |
||||||
|
} |
||||||
|
|
||||||
|
hr { |
||||||
|
margin-top: -1.6em; |
||||||
|
margin-bottom: 0; |
||||||
|
} |
||||||
|
|
||||||
|
hr.short { |
||||||
|
max-width: 30rem; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
/* |
||||||
|
* Copyright © 2020 A Bunch Tell LLC. |
||||||
|
* |
||||||
|
* This file is part of WriteFreely. |
||||||
|
* |
||||||
|
* WriteFreely is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU Affero General Public License, included |
||||||
|
* in the LICENSE file in this source code package. |
||||||
|
*/ |
||||||
|
|
||||||
|
package migrations |
||||||
|
|
||||||
|
import ( |
||||||
|
"context" |
||||||
|
"database/sql" |
||||||
|
|
||||||
|
wf_db "github.com/writeas/writefreely/db" |
||||||
|
) |
||||||
|
|
||||||
|
func oauthInvites(db *datastore) error { |
||||||
|
dialect := wf_db.DialectMySQL |
||||||
|
if db.driverName == driverSQLite { |
||||||
|
dialect = wf_db.DialectSQLite |
||||||
|
} |
||||||
|
return wf_db.RunTransactionWithOptions(context.Background(), db.DB, &sql.TxOptions{}, func(ctx context.Context, tx *sql.Tx) error { |
||||||
|
builders := []wf_db.SQLBuilder{ |
||||||
|
dialect. |
||||||
|
AlterTable("oauth_client_states"). |
||||||
|
AddColumn(dialect.Column("invite_code", wf_db.ColumnTypeChar, wf_db.OptionalInt{ |
||||||
|
Set: true, |
||||||
|
Value: 6, |
||||||
|
}).SetNullable(true)), |
||||||
|
} |
||||||
|
for _, builder := range builders { |
||||||
|
query, err := builder.ToSQL() |
||||||
|
if err != nil { |
||||||
|
return err |
||||||
|
} |
||||||
|
if _, err := tx.ExecContext(ctx, query); err != nil { |
||||||
|
return err |
||||||
|
} |
||||||
|
} |
||||||
|
return nil |
||||||
|
}) |
||||||
|
} |
Loading…
Reference in new issue