Skip to content

Commit

Permalink
feat: upgrade to Appwrite version 15 and updated website code (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
pahuja-sahil authored Jun 18, 2024
1 parent 3f5387b commit 927e018
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 63 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@types/node": "20.4.10",
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"appwrite": "13.0.2",
"appwrite": "15.0.0",
"autoprefixer": "10.4.14",
"eslint": "8.47.0",
"eslint-config-next": "13.4.13",
Expand Down
10 changes: 5 additions & 5 deletions src/backend/auth.api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { account, db, ID, palettegramDB, usersCollection, Query } from "./appwrite.config";
import { generateAvatar } from "@/helper/avatarGenerator";
import { Models } from "appwrite";
import { Models, OAuthProvider } from "appwrite";

/**
* @abstract Register the user into the database
Expand Down Expand Up @@ -31,7 +31,7 @@ const register = async (userData: {
throw new Error("User registration failed");
}

const session = await account.createEmailSession(userData.email, userData.password);
const session = await account.createEmailPasswordSession(userData.email, userData.password);

if (!session) {
throw new Error("Session failed");
Expand Down Expand Up @@ -145,7 +145,7 @@ const getUserByUserId = async (userId: string) => {
const login = async (email: string, password: string) => {
try {
await account.deleteSessions();
const response = await account.createEmailSession(email, password);
const response = await account.createEmailPasswordSession(email, password);

if (!response) {
throw new Error("Login failed");
Expand Down Expand Up @@ -203,7 +203,7 @@ const updatepassword = async (userData: any) => {
if (password === "" || confirmpassword === "" || USER_ID === "" || SECRET === " ") {
throw new Error("Request has failed");
}
const response = await account.updateRecovery(USER_ID, SECRET, password, confirmpassword);
const response = await account.updateRecovery(USER_ID, SECRET, password);
return response;
} catch (error: any) {
console.log(error);
Expand Down Expand Up @@ -287,7 +287,7 @@ const getSingleUser = async (email: string) => {
const loginWithGithub = async () => {
try {
account.createOAuth2Session(
"github",
OAuthProvider.Github,
`${process.env.NEXT_PUBLIC_BASE_URL}/feed`,
`${process.env.NEXT_PUBLIC_BASE_URL}/login`,
["repo", "user"],
Expand Down
3 changes: 2 additions & 1 deletion src/types/auth.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ export type userCollectionDB = {
// };

export type userDetails = {
data: userCollectionDB | {};
data: userCollectionDB | unknown;
error: boolean;
loading: boolean;
accountId?:string;
};

export enum LoginOptions {
Expand Down
63 changes: 7 additions & 56 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1017,13 +1017,10 @@ anymatch@~3.1.2:
normalize-path "^3.0.0"
picomatch "^2.0.4"

[email protected]:
version "13.0.2"
resolved "https://registry.npmjs.org/appwrite/-/appwrite-13.0.2.tgz"
integrity sha512-ISkUXO8pojDWGx5XqknCwwikgAQye4Ni4FL+Ns8Hg42rXeyehLlmvHGjFOmpS+odT6nsWYUaXzVjV4SZuDorog==
dependencies:
cross-fetch "3.1.5"
isomorphic-form-data "2.0.0"
appwrite@^15.0.0:
version "15.0.0"
resolved "https://registry.yarnpkg.com/appwrite/-/appwrite-15.0.0.tgz#73d609fe5c3a4bc9c87a651a8d7c21ef002e8c22"
integrity sha512-rzmo+87tizYLs3YnRLets+vMUF85S/OHkgiGgp0UKcKJj0U1RktAsuIecFqRROKfkqs0fKzggRAIs3RCoYQQwA==

arg@^4.1.0:
version "4.1.3"
Expand Down Expand Up @@ -1400,7 +1397,7 @@ colorette@^2.0.20:
resolved "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz"
integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==

combined-stream@^1.0.6, combined-stream@^1.0.8:
combined-stream@^1.0.8:
version "1.0.8"
resolved "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
Expand Down Expand Up @@ -1515,13 +1512,6 @@ crelt@^1.0.0:
resolved "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz"
integrity sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==

[email protected]:
version "3.1.5"
resolved "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz"
integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==
dependencies:
node-fetch "2.6.7"

cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz"
Expand Down Expand Up @@ -2282,15 +2272,6 @@ foreground-child@^3.1.0:
cross-spawn "^7.0.0"
signal-exit "^4.0.1"

form-data@^2.3.2:
version "2.5.1"
resolved "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz"
integrity sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.6"
mime-types "^2.1.12"

form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz"
Expand Down Expand Up @@ -2935,13 +2916,6 @@ isexe@^2.0.0:
resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==

[email protected]:
version "2.0.0"
resolved "https://registry.npmjs.org/isomorphic-form-data/-/isomorphic-form-data-2.0.0.tgz"
integrity sha512-TYgVnXWeESVmQSg4GLVbalmQ+B4NPi/H4eWxqALKj63KsUrcu301YDjBqaOw3h+cbak7Na4Xyps3BiptHtxTfg==
dependencies:
form-data "^2.3.2"

iterator.prototype@^1.1.2:
version "1.1.2"
resolved "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.2.tgz"
Expand Down Expand Up @@ -3412,13 +3386,6 @@ node-appwrite@^11.1.0:
axios "^1.4.0"
form-data "^4.0.0"

[email protected]:
version "2.6.7"
resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
dependencies:
whatwg-url "^5.0.0"

node-releases@^2.0.14:
version "2.0.14"
resolved "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz"
Expand Down Expand Up @@ -4460,6 +4427,7 @@ [email protected]:
integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
name string-width-cjs
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -4706,11 +4674,6 @@ toggle-selection@^1.0.6:
resolved "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz"
integrity sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==

tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz"
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==

ts-api-utils@^1.0.1:
version "1.3.0"
resolved "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz"
Expand Down Expand Up @@ -4899,19 +4862,6 @@ [email protected]:
glob-to-regexp "^0.4.1"
graceful-fs "^4.1.2"

webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz"
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==

whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz"
integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==
dependencies:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"

which-boxed-primitive@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz"
Expand Down Expand Up @@ -4970,6 +4920,7 @@ which@^2.0.1:
isexe "^2.0.0"

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
name wrap-ansi-cjs
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down

0 comments on commit 927e018

Please sign in to comment.